This repository has been archived by the owner on Sep 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a20c26
commit f07019d
Showing
29 changed files
with
876 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-android-extensions' | ||
|
||
android { | ||
compileSdkVersion rootProject.ext.compileSdkVersion | ||
defaultConfig { | ||
applicationId "com.example.android.cardview" | ||
minSdkVersion rootProject.ext.minSdkVersion | ||
targetSdkVersion rootProject.ext.targetSdkVersion | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
sourceSets { | ||
main { | ||
java.srcDirs "src/main/java" | ||
res.srcDirs "src/main/res" | ||
} | ||
androidTest.setRoot('tests') | ||
androidTest.java.srcDirs = ['tests/src'] | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation'com.android.support:cardview-v7:27.0.2' | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlinVersion" | ||
androidTestImplementation "com.android.support.test.espresso:espresso-core:$rootProject.ext.espressoVersion" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2017 The Android Open Source Project | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.android.cardview"> | ||
|
||
<application | ||
android:allowBackup="false" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
<activity | ||
android:name=".CardViewActivity" | ||
android:label="@string/app_name" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
37 changes: 37 additions & 0 deletions
37
kotlinApp/Application/src/main/java/com/example/android/cardview/CardViewActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2017 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.example.android.cardview | ||
|
||
import android.app.Activity | ||
import android.os.Bundle | ||
|
||
/** | ||
* Launcher Activity for the CardView sample app. | ||
*/ | ||
class CardViewActivity : Activity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_card_view) | ||
if (savedInstanceState == null) { | ||
fragmentManager.beginTransaction() | ||
.add(R.id.container, CardViewFragment()) | ||
.commit() | ||
} | ||
} | ||
|
||
} |
82 changes: 82 additions & 0 deletions
82
kotlinApp/Application/src/main/java/com/example/android/cardview/CardViewFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright (C) 2017 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.example.android.cardview | ||
|
||
import android.app.Fragment | ||
import android.os.Bundle | ||
import android.support.annotation.VisibleForTesting | ||
import android.support.v7.widget.CardView | ||
import android.util.Log | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.SeekBar | ||
|
||
/** | ||
* Fragment that demonstrates how to use [CardView]. | ||
*/ | ||
class CardViewFragment : Fragment() { | ||
|
||
private val TAG = "CardViewFragment" | ||
|
||
// The [CardView] widget. | ||
@VisibleForTesting lateinit var cardView: CardView | ||
|
||
// SeekBar that changes the cornerRadius attribute for the cardView widget. | ||
@VisibleForTesting lateinit var radiusSeekBar: SeekBar | ||
|
||
// SeekBar that changes the Elevation attribute for the cardView widget. | ||
@VisibleForTesting lateinit var elevationSeekBar: SeekBar | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
return inflater.inflate(R.layout.fragment_card_view, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
cardView = view.findViewById(R.id.cardview) | ||
|
||
radiusSeekBar = view.findViewById(R.id.cardview_radius_seekbar) | ||
radiusSeekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { | ||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { | ||
Log.d(TAG, "SeekBar Radius progress: $progress") | ||
cardView.radius = progress.toFloat() | ||
} | ||
|
||
override fun onStartTrackingTouch(seekBar: SeekBar) = Unit // Do nothing | ||
|
||
override fun onStopTrackingTouch(seekBar: SeekBar) = Unit // Do nothing | ||
}) | ||
|
||
elevationSeekBar = view.findViewById(R.id.cardview_elevation_seekbar) | ||
elevationSeekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { | ||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { | ||
Log.d(TAG, "SeekBar Elevation progress : $progress") | ||
cardView.elevation = progress.toFloat() | ||
} | ||
|
||
override fun onStartTrackingTouch(seekBar: SeekBar) = Unit // Do nothing | ||
|
||
override fun onStopTrackingTouch(seekBar: SeekBar) = Unit // Do nothing | ||
}) | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions
28
kotlinApp/Application/src/main/res/layout/activity_card_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2017 The Android Open Source Project | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/container" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
tools:context="com.example.android.cardview.CardViewActivity" | ||
tools:ignore="MergeRootFrame" /> |
91 changes: 91 additions & 0 deletions
91
kotlinApp/Application/src/main/res/layout/fragment_card_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2017 The Android Open Source Project | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:card_view="http://schemas.android.com/apk/res-auto" | ||
android:layout_height="match_parent" | ||
android:layout_width="match_parent"> | ||
|
||
<LinearLayout android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin"> | ||
|
||
<android.support.v7.widget.CardView | ||
android:id="@+id/cardview" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:elevation="@dimen/card_elevation" | ||
card_view:cardBackgroundColor="@color/cardview_initial_background" | ||
card_view:cardCornerRadius="@dimen/card_radius" | ||
android:layout_marginLeft="@dimen/margin_large" | ||
android:layout_marginRight="@dimen/margin_large"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/margin_medium" | ||
android:text="@string/cardview_contents"/> | ||
|
||
</android.support.v7.widget.CardView> | ||
|
||
<LinearLayout | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/margin_large" | ||
android:orientation="horizontal"> | ||
|
||
<TextView | ||
android:layout_width="@dimen/seekbar_label_length" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_vertical" | ||
android:text="@string/cardview_radius_seekbar_text" /> | ||
|
||
<SeekBar | ||
android:id="@+id/cardview_radius_seekbar" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/margin_medium"/> | ||
|
||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
|
||
<TextView | ||
android:layout_width="@dimen/seekbar_label_length" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_vertical" | ||
android:text="@string/cardview_elevation_seekbar_text"/> | ||
|
||
<SeekBar | ||
android:id="@+id/cardview_elevation_seekbar" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/margin_medium"/> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> | ||
|
||
</ScrollView> | ||
|
Oops, something went wrong.