├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── libraries
│ ├── animated_vector_drawable_25_3_0.xml
│ ├── appcompat_v7_25_3_0.xml
│ ├── cardview_v7_25_0_0.xml
│ ├── design_25_0_0.xml
│ ├── palette_v7_25_0_0.xml
│ ├── pinyin4j_2_5_0.xml
│ ├── recyclerview_v7_25_3_0.xml
│ ├── support_annotations_25_3_0.xml
│ ├── support_compat_25_3_0.xml
│ ├── support_core_ui_25_3_0.xml
│ ├── support_core_utils_25_3_0.xml
│ ├── support_fragment_25_3_0.xml
│ ├── support_media_compat_25_3_0.xml
│ ├── support_v4_25_3_0.xml
│ ├── support_vector_drawable_25_3_0.xml
│ └── transition_25_0_0.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── libs
│ └── pinyin4j-2.5.0.jar
├── proguard-rules.pro
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── lqr
│ │ │ └── materialdesigndemo
│ │ │ ├── activity
│ │ │ ├── Android5NewFeatureActivity.java
│ │ │ ├── Applayout1Activity.java
│ │ │ ├── Applayout2Activity.java
│ │ │ ├── Applayout3Activity.java
│ │ │ ├── Applayout4Activity.java
│ │ │ ├── Applayout5Activity.java
│ │ │ ├── Applayout6Activity.java
│ │ │ ├── BehaviorActivity1.java
│ │ │ ├── BehaviorActivity2.java
│ │ │ ├── CardViewActivity.java
│ │ │ ├── FakeFabInteractiveActivity.java
│ │ │ ├── FloatingActionButtonActivity.java
│ │ │ ├── ImmersiveActivity.java
│ │ │ ├── ItemTouchHelperActivity.java
│ │ │ ├── LinearLayoutCompatActivity.java
│ │ │ ├── ListPopupWindowActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── ObjectAnimationActivity.java
│ │ │ ├── ObjectAnimationActivity2.java
│ │ │ ├── PaletteActivity.java
│ │ │ ├── PaletteActivity2.java
│ │ │ ├── PopupMenuActivity.java
│ │ │ ├── RecyclerVIewDecorationActivityOne.java
│ │ │ ├── RecyclerVIewDecorationActivityThree.java
│ │ │ ├── RecyclerVIewDecorationActivityTwo.java
│ │ │ ├── RecyclerViewActivity.java
│ │ │ ├── SearchViewActivity.java
│ │ │ ├── SearchViewActivity2.java
│ │ │ ├── SwipeRefreshLayoutActivity.java
│ │ │ ├── TabLayoutActivity.java
│ │ │ ├── TextInputLayoutActivity.java
│ │ │ └── TransparentToolbarActivity.java
│ │ │ ├── adapter
│ │ │ ├── ItemTouchHelperAdapter.java
│ │ │ ├── MyAdapter.java
│ │ │ ├── MyStaggeredAdapter.java
│ │ │ └── PaletteGridAdapter.java
│ │ │ ├── behavior
│ │ │ ├── CustomerBehavior1.java
│ │ │ └── CustomerBehavior2.java
│ │ │ ├── callback
│ │ │ └── MyItemTouchHelperCallback.java
│ │ │ ├── data
│ │ │ └── Cheeses.java
│ │ │ ├── decoration
│ │ │ ├── MyDecorationOne.java
│ │ │ ├── MyDecorationThree.java
│ │ │ └── MyDecorationTwo.java
│ │ │ ├── fragment
│ │ │ └── TextFragment.java
│ │ │ ├── listener
│ │ │ ├── FakeFabActionListner.java
│ │ │ ├── FakeFabScrollListener.java
│ │ │ ├── ItemDragListener.java
│ │ │ └── ItemMoveListener.java
│ │ │ └── utils
│ │ │ └── PinyinUtils.java
│ └── res
│ │ ├── drawable
│ │ ├── cardview_z_translation.xml
│ │ ├── divider.xml
│ │ ├── divider_vertical.xml
│ │ ├── line.xml
│ │ └── shape_fake_fab.xml
│ │ ├── layout
│ │ ├── activity_android_5_new_features.xml
│ │ ├── activity_applayout1.xml
│ │ ├── activity_applayout2.xml
│ │ ├── activity_applayout3.xml
│ │ ├── activity_applayout4.xml
│ │ ├── activity_applayout5.xml
│ │ ├── activity_applayout6.xml
│ │ ├── activity_behavior1.xml
│ │ ├── activity_behavior2.xml
│ │ ├── activity_card_view.xml
│ │ ├── activity_fake_fab_interactive.xml
│ │ ├── activity_floating_action_button.xml
│ │ ├── activity_immersive.xml
│ │ ├── activity_linear_layout_compat.xml
│ │ ├── activity_list_popup_window.xml
│ │ ├── activity_main.xml
│ │ ├── activity_object_animation.xml
│ │ ├── activity_object_animation2.xml
│ │ ├── activity_palette.xml
│ │ ├── activity_palette2.xml
│ │ ├── activity_popup_menu.xml
│ │ ├── activity_recycler_view.xml
│ │ ├── activity_search_view.xml
│ │ ├── activity_search_view2.xml
│ │ ├── activity_swipe_refresh_layout.xml
│ │ ├── activity_tab_layout.xml
│ │ ├── activity_text_input_layout.xml
│ │ ├── activity_transparent_toolbar.xml
│ │ ├── item_layout.xml
│ │ ├── item_palette.xml
│ │ ├── item_touch_helper.xml
│ │ └── lqr_search_view.xml
│ │ ├── menu
│ │ ├── main.xml
│ │ ├── recycler_view.xml
│ │ └── search_view.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_add_white_24dp.png
│ │ ├── ic_drag.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── icon_1.png
│ │ ├── icon_2.png
│ │ ├── p1.jpg
│ │ ├── p10.jpg
│ │ ├── p11.jpg
│ │ ├── p12.jpg
│ │ ├── p13.jpg
│ │ ├── p14.jpg
│ │ ├── p15.jpg
│ │ ├── p16.jpg
│ │ ├── p17.jpg
│ │ ├── p18.jpg
│ │ ├── p19.jpg
│ │ ├── p2.jpg
│ │ ├── p20.jpg
│ │ ├── p21.jpg
│ │ ├── p22.jpg
│ │ ├── p23.jpg
│ │ ├── p24.jpg
│ │ ├── p25.jpg
│ │ ├── p26.jpg
│ │ ├── p27.jpg
│ │ ├── p28.jpg
│ │ ├── p29.jpg
│ │ ├── p3.jpg
│ │ ├── p30.jpg
│ │ ├── p31.jpg
│ │ ├── p32.jpg
│ │ ├── p33.jpg
│ │ ├── p34.jpg
│ │ ├── p35.jpg
│ │ ├── p36.jpg
│ │ ├── p37.jpg
│ │ ├── p38.jpg
│ │ ├── p39.jpg
│ │ ├── p4.jpg
│ │ ├── p40.jpg
│ │ ├── p41.jpg
│ │ ├── p42.jpg
│ │ ├── p43.jpg
│ │ ├── p44.jpg
│ │ ├── p5.jpg
│ │ ├── p6.jpg
│ │ ├── p7.jpg
│ │ ├── p8.jpg
│ │ ├── p9.jpg
│ │ └── palette.jpg
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── lg.png
│ │ ├── lq.png
│ │ ├── lt.png
│ │ ├── lv.png
│ │ ├── lw.png
│ │ └── m5.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values-v21
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── lqr
│ └── materialdesigndemo
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshots
├── 1.gif
├── 2.gif
├── 3.gif
├── 4.gif
└── 5.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 |
39 | # Keystore files
40 | *.jks
41 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/libraries/animated_vector_drawable_25_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/appcompat_v7_25_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/cardview_v7_25_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/design_25_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/palette_v7_25_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/pinyin4j_2_5_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/libraries/recyclerview_v7_25_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_annotations_25_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/support_compat_25_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_core_ui_25_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_core_utils_25_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_fragment_25_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_media_compat_25_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/support_v4_25_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/libraries/support_vector_drawable_25_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/transition_25_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | 1.8
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 CSDN_LQR
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 创建本Demo主要是为了学习Material Design新控件,具体内容,请看以下文章:
2 |
3 | 1. [Material Design 兼容性控件学习](http://www.jianshu.com/p/a0c246013b8c)
4 | 2. [RecyclerView之ItemDecoration](http://www.jianshu.com/p/7553f5588098)
5 | 3. [RecyclerView之使用ItemTouchHelper实现交互动画](http://www.jianshu.com/p/e3426dcc8ef1)
6 | 4. [MaterialDesign之SearchView全面解锁](http://www.jianshu.com/p/7c1e78e91506)
7 | 5. [MaterialDesign之学一波Palette](http://www.jianshu.com/p/b1255dde624a)
8 | 6. [MaterialDesign之对TabLayout的探索](http://www.jianshu.com/p/bbefb97cccdd)
9 | 7. [MaterialDesign之AppBarLayout与CollapsingToolbarLayout的学习](http://www.jianshu.com/p/91a56cf5e865)
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.lqr.materialdesigndemo"
8 | minSdkVersion 16
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | compile 'com.android.support:appcompat-v7:25.3.0'
25 | compile 'com.android.support:design:25.0.0'
26 | compile 'com.android.support:palette-v7:25.0.0'
27 | compile 'com.android.support:cardview-v7:25.0.0'
28 | compile 'com.android.support:recyclerview-v7:25.3.0'
29 | compile files('libs/pinyin4j-2.5.0.jar')
30 | }
31 |
--------------------------------------------------------------------------------
/app/libs/pinyin4j-2.5.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/libs/pinyin4j-2.5.0.jar
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Program Files\android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/Android5NewFeatureActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.animation.Animator;
4 | import android.annotation.TargetApi;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.view.View;
10 | import android.view.ViewAnimationUtils;
11 | import android.view.animation.AccelerateInterpolator;
12 | import android.widget.Button;
13 | import android.widget.Toast;
14 |
15 | import com.lqr.materialdesigndemo.R;
16 |
17 | /**
18 | * @创建者 CSDN_LQR
19 | * @描述 安卓5.0新特性
20 | */
21 | public class Android5NewFeatureActivity extends AppCompatActivity {
22 | @Override
23 | protected void onCreate(@Nullable Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
26 | Toast.makeText(getApplicationContext(), "版本必须是5.0以上", Toast.LENGTH_SHORT).show();
27 | return;
28 | }
29 | setContentView(R.layout.activity_android_5_new_features);
30 |
31 | button();
32 | revealEffect();
33 | }
34 |
35 |
36 | private void button() {
37 | /**
38 | * Android5.0以上,默认按钮就有水波纹效果。
39 | * 如果需要让人其他控件也有水波纹效果,可以设置控件的backgroun为?attr/selectableItemBackground(方形)或?attr/selectableItemBackgroundBorderless(圆形)。
40 | * 一旦其他控件设置了水波纹效果,则background则被占用,如果需要修改控件的水波纹颜色,则需要在style.xml中设置Activity的样式主题两个不同的属性:
41 | * - #fff
未点击时颜色
42 | * - #D33A31
点击时颜色
43 | */
44 | }
45 |
46 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
47 | private void revealEffect() {
48 | final Button btnReveal1 = (Button) findViewById(R.id.btn_reveal_1);
49 | btnReveal1.setOnClickListener(new View.OnClickListener() {
50 | @Override
51 | public void onClick(View v) {
52 | Animator circularReveal = ViewAnimationUtils.createCircularReveal(btnReveal1, btnReveal1.getWidth() / 2, btnReveal1.getHeight() / 2, 0, (float) Math.hypot(btnReveal1.getWidth(), btnReveal1.getHeight()));
53 | circularReveal.setDuration(1000);
54 | circularReveal.setInterpolator(new AccelerateInterpolator());
55 | circularReveal.start();
56 | }
57 | });
58 |
59 | final Button btnReveal2 = (Button) findViewById(R.id.btn_reveal_2);
60 | btnReveal2.setOnClickListener(new View.OnClickListener() {
61 | @Override
62 | public void onClick(View v) {
63 | Animator circularReveal = ViewAnimationUtils.createCircularReveal(btnReveal2, 0, 0, 0, (float) Math.hypot(btnReveal2.getWidth(), btnReveal2.getHeight()));
64 | circularReveal.setDuration(1000);
65 | circularReveal.setInterpolator(new AccelerateInterpolator());
66 | circularReveal.start();
67 | }
68 | });
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/Applayout1Activity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.webkit.WebView;
8 |
9 | import com.lqr.materialdesigndemo.R;
10 |
11 | public class Applayout1Activity extends AppCompatActivity {
12 |
13 | private Toolbar mToolbar;
14 | private WebView mWebView;
15 |
16 | @Override
17 | protected void onCreate(@Nullable Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_applayout1);
20 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
21 | mWebView = (WebView) findViewById(R.id.webview);
22 | mWebView.loadUrl("https://github.com/GitLqr");
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/Applayout2Activity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.webkit.WebView;
8 |
9 | import com.lqr.materialdesigndemo.R;
10 |
11 | public class Applayout2Activity extends AppCompatActivity {
12 |
13 | private Toolbar mToolbar;
14 | private WebView mWebView;
15 |
16 | @Override
17 | protected void onCreate(@Nullable Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_applayout2);
20 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
21 | mWebView = (WebView) findViewById(R.id.webview);
22 | mWebView.loadUrl("https://github.com/GitLqr");
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/Applayout3Activity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.webkit.WebView;
8 |
9 | import com.lqr.materialdesigndemo.R;
10 |
11 | public class Applayout3Activity extends AppCompatActivity {
12 |
13 | private Toolbar mToolbar;
14 | private WebView mWebView;
15 |
16 | @Override
17 | protected void onCreate(@Nullable Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_applayout3);
20 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
21 | mWebView = (WebView) findViewById(R.id.webview);
22 | mWebView.loadUrl("https://github.com/GitLqr");
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/Applayout4Activity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.webkit.WebView;
8 |
9 | import com.lqr.materialdesigndemo.R;
10 |
11 | public class Applayout4Activity extends AppCompatActivity {
12 |
13 | private Toolbar mToolbar;
14 | private WebView mWebView;
15 |
16 | @Override
17 | protected void onCreate(@Nullable Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_applayout4);
20 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
21 | mWebView = (WebView) findViewById(R.id.webview);
22 | mWebView.loadUrl("https://github.com/GitLqr");
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/Applayout5Activity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.webkit.WebView;
8 |
9 | import com.lqr.materialdesigndemo.R;
10 |
11 | public class Applayout5Activity extends AppCompatActivity {
12 |
13 | private Toolbar mToolbar;
14 | private WebView mWebView;
15 |
16 | @Override
17 | protected void onCreate(@Nullable Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_applayout5);
20 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
21 | mWebView = (WebView) findViewById(R.id.webview);
22 | mWebView.loadUrl("https://github.com/GitLqr");
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/Applayout6Activity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.webkit.WebView;
8 |
9 | import com.lqr.materialdesigndemo.R;
10 |
11 | public class Applayout6Activity extends AppCompatActivity {
12 |
13 | private Toolbar mToolbar;
14 | private WebView mWebView;
15 |
16 | @Override
17 | protected void onCreate(@Nullable Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_applayout6);
20 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
21 | mWebView = (WebView) findViewById(R.id.webview);
22 | mWebView.loadUrl("https://github.com/GitLqr");
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/BehaviorActivity1.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.view.ViewCompat;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.TextView;
9 |
10 | import com.lqr.materialdesigndemo.R;
11 |
12 |
13 | public class BehaviorActivity1 extends AppCompatActivity {
14 |
15 | private TextView mTv1;
16 |
17 | @Override
18 | protected void onCreate(@Nullable Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_behavior1);
21 | mTv1 = (TextView) findViewById(R.id.tv1);
22 | mTv1.setOnClickListener(new View.OnClickListener() {
23 | @Override
24 | public void onClick(View v) {
25 | ViewCompat.offsetTopAndBottom(mTv1, 200);
26 | }
27 | });
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/BehaviorActivity2.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 |
7 | import com.lqr.materialdesigndemo.R;
8 |
9 | public class BehaviorActivity2 extends AppCompatActivity {
10 |
11 | @Override
12 | protected void onCreate(@Nullable Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_behavior2);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/CardViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 |
7 | import com.lqr.materialdesigndemo.R;
8 |
9 | /**
10 | * @创建者 CSDN_LQR
11 | * @描述 学习CardView、水波纹、按压效果
12 | *
13 | * 一、CardView:
14 | * app:cardCornerRadius="10dp" 圆角大小(值越大,角越圆)
15 | * app:cardElevation="5dp" 阴影效果(值越大,效果越明显)
16 | * 1、边框圆角效果:
17 | * 1)5.x图片的布局都可以很好的呈现圆角效果,图片默认也可以变圆角
18 | * 2)4.x图片不能变圆角,如果要做成5.x一样的效果:通过加载图片的时候自己处理成圆角
19 | * 2、margin:
20 | * 1)5.x上面,边距阴影比较小,需要手动添加边距(16dp最好)
21 | * 2)4.x上面,边距太大,手动修改边距为0dp(原因:兼容包里面设置阴影效果自动设置了margin来处理,边距为16dp)
22 | *
23 | * 二、水波纹(4.x不支持):
24 | * android:clickable="true"
25 | * android:foreground="?attr/selectableItemBackground"
26 | *
27 | * 三、按压效果(4.x不支持):
28 | * 创建cardview_z_translation.xml,其中包含属性动画(objectAnimator,它的所有属性不会有提示,请参考着手写)
29 | * 在需要按压效果的控件上设置:android:stateListAnimator="@drawable/cardview_z_translation"(cardview_z_translation.xml可以放在drawable,或者anim)
30 | */
31 | public class CardViewActivity extends AppCompatActivity {
32 | @Override
33 | protected void onCreate(@Nullable Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | setContentView(R.layout.activity_card_view);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/FakeFabInteractiveActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.support.v7.widget.Toolbar;
9 | import android.view.ViewGroup;
10 | import android.view.animation.AccelerateInterpolator;
11 | import android.widget.ImageButton;
12 |
13 | import com.lqr.materialdesigndemo.R;
14 | import com.lqr.materialdesigndemo.adapter.MyAdapter;
15 | import com.lqr.materialdesigndemo.data.Cheeses;
16 | import com.lqr.materialdesigndemo.listener.FakeFabActionListner;
17 | import com.lqr.materialdesigndemo.listener.FakeFabScrollListener;
18 |
19 | import java.util.Arrays;
20 | import java.util.List;
21 |
22 | /**
23 | * @创建者 CSDN_LQR
24 | * @描述 仿Fab与RecyclerView的交互动画
25 | */
26 | public class FakeFabInteractiveActivity extends AppCompatActivity implements FakeFabActionListner {
27 |
28 | private List mData = Arrays.asList(Cheeses.sCheeseStrings);
29 | private Toolbar mToolbar;
30 | private RecyclerView mRv;
31 | private ImageButton mFab;
32 | private int mToolbarBottomMargin;
33 | private int mFabBottomMargin;
34 |
35 | @Override
36 | protected void onCreate(@Nullable Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 | setContentView(R.layout.activity_fake_fab_interactive);
39 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
40 | setSupportActionBar(mToolbar);
41 | mRv = (RecyclerView) findViewById(R.id.rv);
42 | mFab = (ImageButton) findViewById(R.id.fab);
43 |
44 |
45 | mToolbarBottomMargin = ((ViewGroup.MarginLayoutParams) mToolbar.getLayoutParams()).bottomMargin;
46 | mFabBottomMargin = ((ViewGroup.MarginLayoutParams) mFab.getLayoutParams()).bottomMargin;
47 |
48 | mRv.setLayoutManager(new LinearLayoutManager(this));
49 | mRv.setAdapter(new MyAdapter(mData));
50 | mRv.addOnScrollListener(new FakeFabScrollListener(this));
51 | }
52 |
53 | @Override
54 | public void hide() {
55 | mToolbar.animate().translationY(-(mToolbar.getHeight() + mToolbarBottomMargin)).setInterpolator(new AccelerateInterpolator(3));
56 | mFab.animate().translationY(mFab.getHeight() + mFabBottomMargin).setInterpolator(new AccelerateInterpolator(3));
57 | }
58 |
59 | @Override
60 | public void show() {
61 | mToolbar.animate().translationY(0).setInterpolator(new AccelerateInterpolator(3));
62 | mFab.animate().translationY(0).setInterpolator(new AccelerateInterpolator(3));
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/FloatingActionButtonActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.animation.ObjectAnimator;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 |
9 | import com.lqr.materialdesigndemo.R;
10 |
11 | /**
12 | * @创建者 CSDN_LQR
13 | * @描述 悬浮动作按钮、水波纹、按压效果
14 | *
15 | * app:elevation="10dp" 阴影效果(值越大,效果越明显)
16 | * app:fabSize="normal"按钮大小(auto、normal、mini)
17 | * 需要注意的是FloatingActionButton需要在4.x上默认存在margin值(默认16dp),所以需要进行适配,让5.x以上的设备margin为16dp,4.x的设备margin为0dp
18 | *
19 | * 水波纹:
20 | * app:pressedTranslationZ="10dp"
21 | *
22 | * 按压效果:
23 | * android:clickable="true"
24 | * app:rippleColor="#ff0"
25 | */
26 | public class FloatingActionButtonActivity extends AppCompatActivity {
27 |
28 | private boolean isReverse = false;
29 |
30 | @Override
31 | protected void onCreate(@Nullable Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_floating_action_button);
34 | }
35 |
36 | /**
37 | * 点击FloatingActionButton时旋转
38 | */
39 | public void rotate(View view) {
40 | int rotate = isReverse ? 180 : -180;
41 | ObjectAnimator.ofFloat(view, "rotation", 0.0f, rotate)
42 | .setDuration(400).start();
43 | isReverse = !isReverse;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/ImmersiveActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.graphics.Color;
4 | import android.os.Build;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.support.v7.widget.Toolbar;
9 | import android.util.DisplayMetrics;
10 | import android.view.Display;
11 | import android.view.View;
12 | import android.view.WindowManager;
13 | import android.widget.LinearLayout;
14 |
15 | import com.lqr.materialdesigndemo.R;
16 |
17 | /**
18 | * @创建者 CSDN_LQR
19 | * @描述 沉浸式
20 | */
21 | public class ImmersiveActivity extends AppCompatActivity {
22 |
23 | private Toolbar mToolbar;
24 | private View mNav;
25 |
26 | @Override
27 | protected void onCreate(@Nullable Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | addFlags();
30 | setContentView(R.layout.activity_immersive);
31 |
32 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
33 | mNav = findViewById(R.id.nav);
34 |
35 | setImmersive(mToolbar, mNav, Color.parseColor("#D33A31"));
36 | }
37 |
38 | private void addFlags() {
39 | // 4.4
40 | if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
41 | // 透明状态栏、透明底部导航栏
42 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
43 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
44 | }
45 | }
46 |
47 | private void setImmersive(View toolbar, View nav, int color) {
48 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
49 | // 5.0 以上自带沉浸式
50 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
51 | // 设置状态栏与导航栏的颜色
52 | getWindow().setStatusBarColor(color);
53 | getWindow().setNavigationBarColor(color);
54 | }
55 | // 4.4
56 | else {
57 | // 设置 Toolbar 高度(多出一个状态栏的高度)
58 | LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) toolbar.getLayoutParams();
59 | int statusBarHeight = getStatusBarHeight();
60 | params.height += statusBarHeight;
61 | toolbar.setLayoutParams(params);
62 |
63 | // 设置设置Toolbar顶部内间距(一个状态栏的高度)
64 | toolbar.setPadding(toolbar.getPaddingLeft(), toolbar.getPaddingTop() + statusBarHeight, toolbar.getPaddingRight(), toolbar.getPaddingBottom());
65 |
66 | // 设置底部导航栏的高度及背景色
67 | if (nav != null && hasNavigationBar()) {
68 | LinearLayout.LayoutParams p = (LinearLayout.LayoutParams) nav.getLayoutParams();
69 | p.height += getNavigationBarHeight();
70 | nav.setLayoutParams(p);
71 | nav.setBackgroundColor(color);
72 | }
73 | }
74 | }
75 | }
76 |
77 | private int getStatusBarHeight() {
78 | return getSystemComponentDimen("status_bar_height");
79 | }
80 |
81 | private int getNavigationBarHeight() {
82 | return getSystemComponentDimen("navigation_bar_height");
83 | }
84 |
85 | private int getSystemComponentDimen(String dimensName) {
86 | int dimen = -1;
87 | try {
88 | Class clazz = Class.forName("com.android.internal.R$dimen");
89 | Object instance = clazz.newInstance();
90 | int dimenId = (int) clazz.getField(dimensName).get(instance);
91 | // dp --> px
92 | dimen = getResources().getDimensionPixelSize(dimenId);
93 | } catch (Exception e) {
94 | e.printStackTrace();
95 | }
96 | return dimen;
97 | }
98 |
99 | /**
100 | * 判断是否手机是否有导航栏
101 | */
102 | private boolean hasNavigationBar() {
103 | Display display = getWindowManager().getDefaultDisplay();
104 | DisplayMetrics displayMetrics = new DisplayMetrics();
105 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
106 | // 获取设备的硬件屏幕高度
107 | display.getRealMetrics(displayMetrics);
108 | int realHeightPixels = displayMetrics.heightPixels;
109 | int realWidthPixels = displayMetrics.widthPixels;
110 |
111 | // 内容区域的屏幕高度
112 | displayMetrics = new DisplayMetrics();
113 | display.getMetrics(displayMetrics);
114 | int heightPixels = displayMetrics.heightPixels;
115 | int widthPixels = displayMetrics.widthPixels;
116 |
117 | int dHight = realHeightPixels - heightPixels;
118 | int dWidth = realWidthPixels - widthPixels;
119 | return dHight > 0 || dWidth > 0;
120 | }
121 | return false;
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/ItemTouchHelperActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.support.v7.widget.helper.ItemTouchHelper;
9 |
10 | import com.lqr.materialdesigndemo.R;
11 | import com.lqr.materialdesigndemo.adapter.ItemTouchHelperAdapter;
12 | import com.lqr.materialdesigndemo.callback.MyItemTouchHelperCallback;
13 | import com.lqr.materialdesigndemo.data.Cheeses;
14 | import com.lqr.materialdesigndemo.listener.ItemDragListener;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Collections;
18 | import java.util.Comparator;
19 | import java.util.List;
20 |
21 |
22 | public class ItemTouchHelperActivity extends AppCompatActivity implements ItemDragListener {
23 |
24 | private List mData = new ArrayList<>();
25 | private RecyclerView mRv;
26 | private ItemTouchHelperAdapter mAdapter;
27 | private MyItemTouchHelperCallback mCallback;
28 | private ItemTouchHelper mItemTouchHelper;
29 |
30 | @Override
31 | protected void onCreate(@Nullable Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_recycler_view);
34 | mRv = (RecyclerView) findViewById(R.id.rv);
35 | initData();
36 | setRecyclerView();
37 | }
38 |
39 | private void initData() {
40 | for (int i = 0; i < Cheeses.sCheeseStrings.length; i++) {
41 | mData.add(Cheeses.sCheeseStrings[i]);
42 | }
43 | Collections.sort(mData, new Comparator() {
44 | @Override
45 | public int compare(String o1, String o2) {
46 | return o1.compareTo(o2);
47 | }
48 | });
49 | }
50 |
51 | private void setRecyclerView() {
52 | mAdapter = new ItemTouchHelperAdapter(mData, this);
53 | mRv.setLayoutManager(new LinearLayoutManager(this));
54 | mRv.setAdapter(mAdapter);
55 |
56 | mCallback = new MyItemTouchHelperCallback(mAdapter);
57 | mItemTouchHelper = new ItemTouchHelper(mCallback);
58 | mItemTouchHelper.attachToRecyclerView(mRv);
59 | }
60 |
61 | @Override
62 | public void onStartDrags(RecyclerView.ViewHolder viewHolder) {
63 | mItemTouchHelper.startDrag(viewHolder);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/LinearLayoutCompatActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.LinearLayoutCompat;
7 | import android.view.View;
8 |
9 | import com.lqr.materialdesigndemo.R;
10 |
11 | /**
12 | * @创建者 CSDN_LQR
13 | * @描述 LinearLayoutCompat可以给子控件添加分隔线
14 | */
15 | public class LinearLayoutCompatActivity extends AppCompatActivity {
16 |
17 | private LinearLayoutCompat mLlc;
18 |
19 | @Override
20 | protected void onCreate(@Nullable Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_linear_layout_compat);
23 | mLlc = (LinearLayoutCompat) findViewById(R.id.llc);
24 | }
25 |
26 | public void beginning(View view) {
27 | mLlc.setShowDividers(LinearLayoutCompat.SHOW_DIVIDER_BEGINNING);
28 | }
29 |
30 | public void middle(View view) {
31 | mLlc.setShowDividers(LinearLayoutCompat.SHOW_DIVIDER_MIDDLE);
32 | }
33 |
34 | public void end(View view) {
35 | mLlc.setShowDividers(LinearLayoutCompat.SHOW_DIVIDER_END);
36 | }
37 |
38 | public void beginning_middle(View view) {
39 | mLlc.setShowDividers(LinearLayoutCompat.SHOW_DIVIDER_BEGINNING | LinearLayoutCompat.SHOW_DIVIDER_MIDDLE);
40 |
41 | }
42 |
43 | public void end_middle(View view) {
44 | mLlc.setShowDividers(LinearLayoutCompat.SHOW_DIVIDER_MIDDLE | LinearLayoutCompat.SHOW_DIVIDER_END);
45 |
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/ListPopupWindowActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.ListPopupWindow;
7 | import android.view.View;
8 | import android.widget.AdapterView;
9 | import android.widget.ArrayAdapter;
10 | import android.widget.Toast;
11 |
12 | import com.lqr.materialdesigndemo.R;
13 |
14 | public class ListPopupWindowActivity extends AppCompatActivity {
15 |
16 | private ListPopupWindow mListPopupWindow;
17 | private ArrayAdapter mAdapter;
18 | private String[] mItemArr;
19 |
20 | @Override
21 | protected void onCreate(@Nullable Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_list_popup_window);
24 | mItemArr = new String[]{"item 1", "item 2", "item 3", "item 4", "item 5", "item 6", "item 7", "item 8"};
25 | mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mItemArr);
26 | }
27 |
28 | public void showPopupWindow(View view) {
29 | if (mListPopupWindow == null)
30 | mListPopupWindow = new ListPopupWindow(this);
31 | //设置 ListPopupWindow 的数据适配器
32 | mListPopupWindow.setAdapter(mAdapter);
33 | //设置 ListPopupWindow 的显示位置(在指定控件下方)
34 | mListPopupWindow.setAnchorView(view);
35 | //设置 ListPopupWindow 的宽度
36 | mListPopupWindow.setWidth(200);
37 | //设置 ListPopupWindow 的高度
38 | mListPopupWindow.setHeight(500);
39 | //设置 ListPopupWindow 的条目点击事件(必须在show方法前设置,否则无效)
40 | mListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
41 | @Override
42 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
43 | Toast.makeText(getApplicationContext(), mItemArr[position], Toast.LENGTH_SHORT).show();
44 | mListPopupWindow.dismiss();
45 | }
46 | });
47 | mListPopupWindow.show();
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 |
8 | import com.lqr.materialdesigndemo.R;
9 |
10 | public class MainActivity extends AppCompatActivity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_main);
16 | getLayoutInflater();
17 | }
18 |
19 | private void jumpToActivity(Class activityClass) {
20 | startActivity(new Intent(this, activityClass));
21 | }
22 |
23 | public void swipeRefreshLayout(View view) {
24 | jumpToActivity(SwipeRefreshLayoutActivity.class);
25 | }
26 |
27 |
28 | public void listPopupWindow(View view) {
29 | jumpToActivity(ListPopupWindowActivity.class);
30 | }
31 |
32 | public void popupMenu(View view) {
33 | jumpToActivity(PopupMenuActivity.class);
34 | }
35 |
36 | public void linearLayoutCompat(View view) {
37 | jumpToActivity(LinearLayoutCompatActivity.class);
38 | }
39 |
40 | public void recyclerView(View view) {
41 | jumpToActivity(RecyclerViewActivity.class);
42 | }
43 |
44 | public void recyclerViewDecorationOne(View view) {
45 | jumpToActivity(RecyclerVIewDecorationActivityOne.class);
46 | }
47 |
48 | public void recyclerViewDecorationTwo(View view) {
49 | jumpToActivity(RecyclerVIewDecorationActivityTwo.class);
50 | }
51 |
52 | public void recyclerViewDecorationThree(View view) {
53 | jumpToActivity(RecyclerVIewDecorationActivityThree.class);
54 | }
55 |
56 | public void itemTouchHelper(View view) {
57 | jumpToActivity(ItemTouchHelperActivity.class);
58 | }
59 |
60 | public void textInputLayout(View view) {
61 | jumpToActivity(TextInputLayoutActivity.class);
62 | }
63 |
64 | public void searchView(View view) {
65 | jumpToActivity(SearchViewActivity.class);
66 | }
67 |
68 | public void searchView2(View view) {
69 | jumpToActivity(SearchViewActivity2.class);
70 | }
71 |
72 | public void transparentToolbar(View view) {
73 | jumpToActivity(TransparentToolbarActivity.class);
74 | }
75 |
76 | public void palette(View view) {
77 | jumpToActivity(PaletteActivity.class);
78 | }
79 |
80 | public void palette2(View view) {
81 | jumpToActivity(PaletteActivity2.class);
82 | }
83 |
84 | public void tabLayout(View view) {
85 | jumpToActivity(TabLayoutActivity.class);
86 | }
87 |
88 | public void immersive(View view) {
89 | jumpToActivity(ImmersiveActivity.class);
90 | }
91 |
92 | public void cardView(View view) {
93 | jumpToActivity(CardViewActivity.class);
94 | }
95 |
96 | public void floatingActionButton(View view) {
97 | jumpToActivity(FloatingActionButtonActivity.class);
98 | }
99 |
100 | public void fakeFabInteractive(View view) {
101 | jumpToActivity(FakeFabInteractiveActivity.class);
102 | }
103 |
104 | public void applayout1(View view) {
105 | jumpToActivity(Applayout1Activity.class);
106 | }
107 |
108 | public void applayout2(View view) {
109 | jumpToActivity(Applayout2Activity.class);
110 | }
111 |
112 | public void applayout3(View view) {
113 | jumpToActivity(Applayout3Activity.class);
114 | }
115 |
116 | public void applayout4(View view) {
117 | jumpToActivity(Applayout4Activity.class);
118 | }
119 |
120 | public void applayout5(View view) {
121 | jumpToActivity(Applayout5Activity.class);
122 | }
123 |
124 | public void applayout6(View view) {
125 | jumpToActivity(Applayout6Activity.class);
126 | }
127 |
128 | public void behavior1(View view) {
129 | jumpToActivity(BehaviorActivity1.class);
130 | }
131 |
132 | public void behavior2(View view) {
133 | jumpToActivity(BehaviorActivity2.class);
134 | }
135 |
136 | public void object_animation(View view) {
137 | jumpToActivity(ObjectAnimationActivity.class);
138 | }
139 |
140 | public void object_animation2(View view) {
141 | jumpToActivity(ObjectAnimationActivity2.class);
142 | }
143 |
144 | public void android5newfeature1(View view) {
145 | jumpToActivity(Android5NewFeatureActivity.class);
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/ObjectAnimationActivity2.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.animation.AnimatorSet;
6 | import android.animation.ObjectAnimator;
7 | import android.os.Bundle;
8 | import android.support.annotation.Nullable;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.view.View;
11 |
12 | import com.lqr.materialdesigndemo.R;
13 |
14 | /**
15 | * @创建者 CSDN_LQR
16 | * @描述 属性动画综合应用
17 | */
18 | public class ObjectAnimationActivity2 extends AppCompatActivity {
19 |
20 | private View mView1;
21 | private View mView2;
22 |
23 | @Override
24 | protected void onCreate(@Nullable Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_object_animation2);
27 | mView1 = findViewById(R.id.view_1);
28 | mView2 = findViewById(R.id.view_2);
29 |
30 | }
31 |
32 | public void startFirstAnimation(View view) {
33 | // 翻转动画
34 | ObjectAnimator rotationXAnimation = ObjectAnimator.ofFloat(mView1, "rotationX", 0f, 25f);
35 | // 透明动画
36 | ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(mView1, "alpha", 1f, 0.5f);
37 | // 缩放动画
38 | ObjectAnimator scaleXAnimation = ObjectAnimator.ofFloat(mView1, "scaleX", 1f, 0.8f);
39 | ObjectAnimator scaleYAnimation = ObjectAnimator.ofFloat(mView1, "scaleY", 1f, 0.8f);
40 | // 位移动画
41 | ObjectAnimator translationYAnimation = ObjectAnimator.ofFloat(mView1, "translationY", 0f, -0.1f * mView1.getHeight());
42 | // 翻转动画
43 | ObjectAnimator rerotationXAnimation = ObjectAnimator.ofFloat(mView1, "rotationX", 25f, 0f);
44 | rerotationXAnimation.setStartDelay(200);
45 | // 位移动画
46 | ObjectAnimator translationYAnimation2 = ObjectAnimator.ofFloat(mView2, "translationY", mView2.getHeight(), 0);
47 | translationYAnimation2.addListener(new AnimatorListenerAdapter() {
48 | @Override
49 | public void onAnimationStart(Animator animation) {
50 | super.onAnimationStart(animation);
51 | mView2.setVisibility(View.VISIBLE);
52 | }
53 | });
54 |
55 | AnimatorSet as = new AnimatorSet();
56 | as.playTogether(rotationXAnimation, alphaAnimation, scaleXAnimation, scaleYAnimation, translationYAnimation, rerotationXAnimation, translationYAnimation2);
57 | as.setDuration(200);
58 | as.start();
59 | }
60 |
61 | public void startSecondAnimation(View view) {
62 | ObjectAnimator rotationXAnimation = ObjectAnimator.ofFloat(mView1, "rotationX", 0f, 25f);
63 | ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(mView1, "alpha", 0.5f, 1f);
64 | ObjectAnimator scaleXAnimation = ObjectAnimator.ofFloat(mView1, "scaleX", 0.8f, 1f);
65 | ObjectAnimator scaleYAnimation = ObjectAnimator.ofFloat(mView1, "scaleY", 0.8f, 1f);
66 | ObjectAnimator translationYAnimation = ObjectAnimator.ofFloat(mView1, "translationY", -0.1f * mView1.getHeight(), 0f);
67 | ObjectAnimator rerotationXAnimation = ObjectAnimator.ofFloat(mView1, "rotationX", 25f, 0f);
68 | rerotationXAnimation.setStartDelay(200);
69 | ObjectAnimator translationYAnimation2 = ObjectAnimator.ofFloat(mView2, "translationY", 0, mView2.getHeight());
70 | translationYAnimation2.addListener(new AnimatorListenerAdapter() {
71 | @Override
72 | public void onAnimationEnd(Animator animation) {
73 | super.onAnimationEnd(animation);
74 | mView2.setVisibility(View.INVISIBLE);
75 | }
76 | });
77 |
78 | AnimatorSet as = new AnimatorSet();
79 | as.playTogether(rotationXAnimation, alphaAnimation, scaleXAnimation, scaleYAnimation,
80 | translationYAnimation,
81 | rerotationXAnimation, translationYAnimation2);
82 | as.setDuration(200);
83 | as.start();
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/PaletteActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.BitmapDrawable;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.graphics.Palette;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 |
13 | import com.lqr.materialdesigndemo.R;
14 |
15 |
16 | public class PaletteActivity extends AppCompatActivity {
17 |
18 | private ImageView mIvPic;
19 | private TextView mTvBody;
20 | private TextView mTvTitle;
21 | private TextView mTvDarkMutedColor;
22 | private TextView mTvLightMutedColor;
23 | private TextView mTvDarkVibrantColor;
24 | private TextView mTvLightVibrantColor;
25 | private TextView mTvMutedColor;
26 | private TextView mTvVibrantColor;
27 |
28 | @Override
29 | protected void onCreate(@Nullable Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_palette);
32 | mIvPic = (ImageView) findViewById(R.id.ivPic);
33 | mTvBody = (TextView) findViewById(R.id.tvBody);
34 | mTvTitle = (TextView) findViewById(R.id.tvTitle);
35 | mTvDarkMutedColor = (TextView) findViewById(R.id.tvDarkMutedColor);
36 | mTvLightMutedColor = (TextView) findViewById(R.id.tvLightMutedColor);
37 | mTvDarkVibrantColor = (TextView) findViewById(R.id.tvDarkVibrantColor);
38 | mTvLightVibrantColor = (TextView) findViewById(R.id.tvLightVibrantColor);
39 | mTvMutedColor = (TextView) findViewById(R.id.tvMutedColor);
40 | mTvVibrantColor = (TextView) findViewById(R.id.tvVibrantColor);
41 |
42 | BitmapDrawable drawable = (BitmapDrawable) mIvPic.getDrawable();
43 | Bitmap bitmap = drawable.getBitmap();
44 |
45 | Palette.Builder builder = Palette.from(bitmap);
46 | builder.maximumColorCount(32); // 构建Palette时使用的最大颜色数,默认是16,风景图推荐取值8-16,人脸图像推荐取值24-32(值越大,花费的时间越长,可选择的色彩越多)
47 | // .setRegion(0, 0, bitmap.getWidth() - 1, bitmap.getHeight()) // 设置Palette颜色分析的图像区域
48 | // .addFilter(new Palette.Filter() { // 设置过滤器来过滤不需要的颜色(目前还不清楚怎么用,网上也找不到任何教程及代码,无从学习~)
49 | // @Override
50 | // public boolean isAllowed(int rgb, float[] hsl) {
51 | // return false;
52 | // }
53 | // })
54 | // .clearRegion()
55 | // .clearFilters();
56 |
57 | builder.generate(new Palette.PaletteAsyncListener() {
58 | @Override
59 | public void onGenerated(Palette palette) {
60 | // 暗、柔和
61 | int darkMutedColor = palette.getDarkMutedColor(Color.BLACK);
62 | // 亮、柔和
63 | int lightMutedColor = palette.getLightMutedColor(Color.BLACK);
64 | // 暗、鲜艳
65 | int darkVibrantColor = palette.getDarkVibrantColor(Color.BLACK);
66 | // 亮、鲜艳
67 | int lightVibrantColor = palette.getLightVibrantColor(Color.BLACK);
68 | // 柔和
69 | int mutedColor = palette.getMutedColor(Color.BLACK);
70 | // 鲜艳
71 | int vibrantColor = palette.getVibrantColor(Color.BLACK);
72 |
73 | // 获取某种色调的样品(这里指柔和的暗色)
74 | Palette.Swatch darkMutedSwatch = palette.getDarkMutedSwatch();
75 | // 获取图片的整体颜色rgb混合值---主色调
76 | int rgb = darkMutedSwatch.getRgb();
77 | // 获取图片中间的文字颜色
78 | int bodyTextColor = darkMutedSwatch.getBodyTextColor();
79 | // 获取作为标题的颜色(有一定的和图片的对比度的颜色值)
80 | int titleTextColor = darkMutedSwatch.getTitleTextColor();
81 | // 颜色向量
82 | float[] hsl = darkMutedSwatch.getHsl();
83 | // 分析该颜色在图片中所占像素值
84 | int population = darkMutedSwatch.getPopulation();
85 |
86 | mTvBody.setBackgroundColor(generateTransparentColor(0.2f, rgb));
87 | mTvBody.setTextColor(bodyTextColor);
88 | mTvTitle.setBackgroundColor(generateTransparentColor(0.6f, rgb));
89 | mTvTitle.setTextColor(titleTextColor);
90 |
91 | mTvDarkMutedColor.setBackgroundColor(darkMutedColor);
92 | mTvLightMutedColor.setBackgroundColor(lightMutedColor);
93 | mTvDarkVibrantColor.setBackgroundColor(darkVibrantColor);
94 | mTvLightVibrantColor.setBackgroundColor(lightVibrantColor);
95 | mTvMutedColor.setBackgroundColor(mutedColor);
96 | mTvVibrantColor.setBackgroundColor(vibrantColor);
97 | }
98 | });
99 | }
100 |
101 | private int generateTransparentColor(float percent, int rgb) {
102 | int red = Color.red(rgb);
103 | int green = Color.green(rgb);
104 | int blue = Color.blue(rgb);
105 | int alpha = Color.alpha(rgb);
106 | alpha = (int) (alpha * percent);
107 | return Color.argb(alpha, red, green, blue);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/PaletteActivity2.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.GridLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 |
9 | import com.lqr.materialdesigndemo.R;
10 | import com.lqr.materialdesigndemo.adapter.PaletteGridAdapter;
11 |
12 |
13 | public class PaletteActivity2 extends AppCompatActivity {
14 |
15 | private RecyclerView mRvPalette;
16 |
17 | @Override
18 | protected void onCreate(@Nullable Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_palette2);
21 | mRvPalette = (RecyclerView) findViewById(R.id.rvPalette);
22 | mRvPalette.setLayoutManager(new GridLayoutManager(this, 2));
23 | mRvPalette.setAdapter(new PaletteGridAdapter());
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/PopupMenuActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.view.menu.MenuPopupHelper;
7 | import android.support.v7.widget.PopupMenu;
8 | import android.view.MenuItem;
9 | import android.view.View;
10 | import android.widget.Toast;
11 |
12 | import com.lqr.materialdesigndemo.R;
13 |
14 | import java.lang.reflect.Field;
15 |
16 | public class PopupMenuActivity extends AppCompatActivity {
17 | @Override
18 | protected void onCreate(@Nullable Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_popup_menu);
21 | }
22 |
23 | public void showPopupMenu(View view) throws NoSuchFieldException, IllegalAccessException {
24 | PopupMenu popupMenu = new PopupMenu(this, view);
25 | //设置 PopupMenu 的显示菜单项
26 | popupMenu.inflate(R.menu.main);
27 | // popupMenu.getMenuInflater().inflate(R.menu.main, popupMenu.getMenu());//与一行没什么区别
28 | //默认 PopupMenu 不显示条目icon,可以通过反射来强制使其显示icon
29 | Field field = popupMenu.getClass().getDeclaredField("mPopup");
30 | field.setAccessible(true);
31 | MenuPopupHelper mHelper = (MenuPopupHelper) field.get(popupMenu);
32 | mHelper.setForceShowIcon(true);
33 | //设置 PopupMenu 的条目点击事件(点击后会自动dismiss)
34 | popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
35 | @Override
36 | public boolean onMenuItemClick(MenuItem item) {
37 | Toast.makeText(getApplicationContext(), item.getTitle(), Toast.LENGTH_SHORT).show();
38 | return false;
39 | }
40 | });
41 | //显示 PopupMenu
42 | popupMenu.show();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerVIewDecorationActivityOne.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 |
9 | import com.lqr.materialdesigndemo.R;
10 | import com.lqr.materialdesigndemo.adapter.MyAdapter;
11 | import com.lqr.materialdesigndemo.decoration.MyDecorationOne;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | /**
17 | * @创建者 CSDN_LQR
18 | * @描述 RecyclerView的分割线
19 | */
20 | public class RecyclerVIewDecorationActivityOne extends AppCompatActivity {
21 |
22 | private List mData = new ArrayList<>();
23 | private RecyclerView mRv;
24 | private MyAdapter mMyAdapter;
25 |
26 | @Override
27 | protected void onCreate(@Nullable Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_recycler_view);
30 | mRv = (RecyclerView) findViewById(R.id.rv);
31 | initView();
32 | initData();
33 | setRecyclerView();
34 | }
35 |
36 | private void initView() {
37 | MyDecorationOne decorationOne = new MyDecorationOne(this, LinearLayoutManager.VERTICAL);
38 | mRv.addItemDecoration(decorationOne);
39 | }
40 |
41 | private void initData() {
42 | for (int i = 0; i < 100; i++) {
43 | mData.add("item " + i);
44 | }
45 | }
46 |
47 | private void setRecyclerView() {
48 | mMyAdapter = new MyAdapter(mData);
49 | mRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
50 | mRv.setAdapter(mMyAdapter);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerVIewDecorationActivityThree.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 |
9 | import com.lqr.materialdesigndemo.R;
10 | import com.lqr.materialdesigndemo.adapter.MyAdapter;
11 | import com.lqr.materialdesigndemo.data.Cheeses;
12 | import com.lqr.materialdesigndemo.decoration.MyDecorationThree;
13 | import com.lqr.materialdesigndemo.utils.PinyinUtils;
14 |
15 | import java.util.ArrayList;
16 | import java.util.Arrays;
17 | import java.util.Collections;
18 | import java.util.Comparator;
19 | import java.util.List;
20 |
21 | /**
22 | * @创建者 CSDN_LQR
23 | * @描述 RecyclerView的侧边字母提示
24 | */
25 | public class RecyclerVIewDecorationActivityThree extends AppCompatActivity {
26 |
27 | private List mData = new ArrayList<>();
28 | private RecyclerView mRv;
29 | private MyAdapter mMyAdapter;
30 |
31 | @Override
32 | protected void onCreate(@Nullable Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_recycler_view);
35 | mRv = (RecyclerView) findViewById(R.id.rv);
36 | initData();
37 | initView();
38 | setRecyclerView();
39 | }
40 |
41 | private void initView() {
42 | MyDecorationThree decorationThree = new MyDecorationThree(this, mData);
43 | mRv.addItemDecoration(decorationThree);
44 | }
45 |
46 | private void initData() {
47 | mData = Arrays.asList(Cheeses.NAMES);
48 | Collections.sort(mData, new Comparator() {
49 | @Override
50 | public int compare(String o1, String o2) {
51 | return PinyinUtils.getPinyin(o1).compareTo(PinyinUtils.getPinyin(o2));
52 | }
53 | });
54 | }
55 |
56 | private void setRecyclerView() {
57 | mMyAdapter = new MyAdapter(mData);
58 | mRv.setLayoutManager(new LinearLayoutManager(this));
59 | mRv.setAdapter(mMyAdapter);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerVIewDecorationActivityTwo.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.GridLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 |
9 | import com.lqr.materialdesigndemo.R;
10 | import com.lqr.materialdesigndemo.adapter.MyAdapter;
11 | import com.lqr.materialdesigndemo.decoration.MyDecorationTwo;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | /**
17 | * @创建者 CSDN_LQR
18 | * @描述 RecyclerView的表格样式
19 | */
20 | public class RecyclerVIewDecorationActivityTwo extends AppCompatActivity {
21 |
22 | private List mData = new ArrayList<>();
23 | private RecyclerView mRv;
24 | private MyAdapter mMyAdapter;
25 |
26 | @Override
27 | protected void onCreate(@Nullable Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_recycler_view);
30 | mRv = (RecyclerView) findViewById(R.id.rv);
31 | initView();
32 | initData();
33 | setRecyclerView();
34 | }
35 |
36 | private void initView() {
37 | MyDecorationTwo decorationTwo = new MyDecorationTwo(this);
38 | mRv.addItemDecoration(decorationTwo);
39 | }
40 |
41 | private void initData() {
42 | for (int i = 0; i < 59; i++) {
43 | mData.add("item " + i);
44 | }
45 | }
46 |
47 | private void setRecyclerView() {
48 | mMyAdapter = new MyAdapter(mData);
49 | mRv.setLayoutManager(new GridLayoutManager(this, 3));
50 | mRv.setAdapter(mMyAdapter);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.GridLayoutManager;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.support.v7.widget.StaggeredGridLayoutManager;
10 | import android.view.Menu;
11 | import android.view.MenuInflater;
12 | import android.view.MenuItem;
13 |
14 | import com.lqr.materialdesigndemo.R;
15 | import com.lqr.materialdesigndemo.adapter.MyAdapter;
16 | import com.lqr.materialdesigndemo.adapter.MyStaggeredAdapter;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 |
22 | public class RecyclerViewActivity extends AppCompatActivity {
23 |
24 | private List mData = new ArrayList<>();
25 | private RecyclerView mRv;
26 | private MyAdapter mMyAdapter;
27 |
28 | @Override
29 | protected void onCreate(@Nullable Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_recycler_view);
32 | mRv = (RecyclerView) findViewById(R.id.rv);
33 | initData();
34 | setRecyclerView();
35 | }
36 |
37 | private void initData() {
38 | for (int i = 0; i < 100; i++) {
39 | mData.add("item " + i);
40 | }
41 | }
42 |
43 | private void setRecyclerView() {
44 | mMyAdapter = new MyAdapter(mData);
45 | mRv.setLayoutManager(new LinearLayoutManager(this));
46 | mRv.setAdapter(mMyAdapter);
47 | }
48 |
49 | @Override
50 | public boolean onCreateOptionsMenu(Menu menu) {
51 | new MenuInflater(this).inflate(R.menu.recycler_view, menu);
52 | return true;
53 | }
54 |
55 | @Override
56 | public boolean onOptionsItemSelected(MenuItem item) {
57 | switch (item.getItemId()) {
58 | case R.id.linear_ver:
59 | mRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
60 | mRv.setAdapter(mMyAdapter);
61 | break;
62 | case R.id.linear_hor:
63 | mRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
64 | mRv.setAdapter(mMyAdapter);
65 | break;
66 | case R.id.grid_ver:
67 | mRv.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
68 | mRv.setAdapter(mMyAdapter);
69 | break;
70 | case R.id.grid_hor:
71 | mRv.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.HORIZONTAL, false));
72 | mRv.setAdapter(mMyAdapter);
73 | break;
74 | case R.id.staggered_ver:
75 | mRv.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
76 | mRv.setAdapter(new MyStaggeredAdapter(mData));
77 | break;
78 | case R.id.staggered_hor:
79 | mRv.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.HORIZONTAL));
80 | mRv.setAdapter(new MyStaggeredAdapter(mData));
81 | break;
82 | }
83 | return true;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/SearchViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.view.MenuItemCompat;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.SearchView;
8 | import android.support.v7.widget.Toolbar;
9 | import android.util.Log;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.view.View;
13 | import android.widget.Toast;
14 |
15 | import com.lqr.materialdesigndemo.R;
16 |
17 |
18 | public class SearchViewActivity extends AppCompatActivity {
19 |
20 | private Toolbar mToolbar;
21 | private SearchView mSearchView;
22 |
23 | @Override
24 | protected void onCreate(@Nullable Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_search_view);
27 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
28 | setSupportActionBar(mToolbar);
29 | }
30 |
31 | @Override
32 | public boolean onCreateOptionsMenu(Menu menu) {
33 | getMenuInflater().inflate(R.menu.search_view, menu);
34 | MenuItem item = menu.findItem(R.id.menu_search);
35 | mSearchView = (SearchView) MenuItemCompat.getActionView(item);
36 |
37 | /*------------------ SearchView有三种默认展开搜索框的设置方式,区别如下: ------------------*/
38 | //设置搜索框直接展开显示。左侧有放大镜(在搜索框中) 右侧有叉叉 可以关闭搜索框
39 | mSearchView.setIconified(false);
40 | //设置搜索框直接展开显示。左侧有放大镜(在搜索框外) 右侧无叉叉 有输入内容后有叉叉 不能关闭搜索框
41 | mSearchView.setIconifiedByDefault(false);
42 | //设置搜索框直接展开显示。左侧有无放大镜(在搜索框中) 右侧无叉叉 有输入内容后有叉叉 不能关闭搜索框
43 | mSearchView.onActionViewExpanded();
44 |
45 | //设置最大宽度
46 | // mSearchView.setMaxWidth(500);
47 | //设置是否显示搜索框展开时的提交按钮
48 | // mSearchView.setSubmitButtonEnabled(true);
49 | //设置输入框提示语
50 | // mSearchView.setQueryHint("hint");
51 |
52 | //搜索框展开时后面叉叉按钮的点击事件
53 | mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
54 | @Override
55 | public boolean onClose() {
56 | Toast.makeText(getApplicationContext(), "Close", Toast.LENGTH_SHORT).show();
57 | return false;
58 | }
59 | });
60 | //搜索图标按钮(打开搜索框的按钮)的点击事件
61 | mSearchView.setOnSearchClickListener(new View.OnClickListener() {
62 | @Override
63 | public void onClick(View v) {
64 | Toast.makeText(getApplicationContext(), "Open", Toast.LENGTH_SHORT).show();
65 | }
66 | });
67 | //搜索框文字变化监听
68 | mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
69 | @Override
70 | public boolean onQueryTextSubmit(String s) {
71 | Log.e("CSDN_LQR", "TextSubmit : " + s);
72 | return false;
73 | }
74 |
75 | @Override
76 | public boolean onQueryTextChange(String s) {
77 | Log.e("CSDN_LQR", "TextChange --> " + s);
78 | return false;
79 | }
80 | });
81 |
82 | // mSearchView.setSuggestionsAdapter();
83 | return super.onCreateOptionsMenu(menu);
84 | }
85 |
86 | @Override
87 | public boolean onOptionsItemSelected(MenuItem item) {
88 | return super.onOptionsItemSelected(item);
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/SwipeRefreshLayoutActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.graphics.Color;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.os.Message;
7 | import android.support.annotation.Nullable;
8 | import android.support.v4.widget.SwipeRefreshLayout;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.view.Gravity;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.AbsListView;
14 | import android.widget.BaseAdapter;
15 | import android.widget.ListView;
16 | import android.widget.TextView;
17 |
18 | import com.lqr.materialdesigndemo.R;
19 |
20 | import java.util.ArrayList;
21 | import java.util.List;
22 |
23 |
24 | public class SwipeRefreshLayoutActivity extends AppCompatActivity {
25 |
26 | private SwipeRefreshLayout mSrl;
27 | private ListView mListView;
28 | private int number = 0;
29 | private List mData = new ArrayList<>();
30 | private BaseAdapter mAdapter;
31 |
32 | private Handler mHandler = new Handler() {
33 | @Override
34 | public void handleMessage(Message msg) {
35 | super.handleMessage(msg);
36 | mAdapter.notifyDataSetChanged();
37 | mSrl.setRefreshing(false);
38 | }
39 | };
40 |
41 | @Override
42 | protected void onCreate(@Nullable Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 | setContentView(R.layout.activity_swipe_refresh_layout);
45 | mSrl = (SwipeRefreshLayout) findViewById(R.id.srl);
46 | mListView = (ListView) findViewById(R.id.lv);
47 | setSwipeRefreshLayout();
48 | setListView();
49 | }
50 |
51 | private void setSwipeRefreshLayout() {
52 | //设置 SwipeRefreshLayout 的尺寸
53 | mSrl.setSize(SwipeRefreshLayout.LARGE);
54 | //设置 SwipeRefreshLayout 刷新时的颜色切换(可以有无数种)
55 | mSrl.setColorSchemeColors(Color.RED, Color.YELLOW, Color.GREEN);
56 | //设置 SwipeRefreshLayout 的背景色
57 | mSrl.setBackgroundColor(Color.GRAY);
58 | //设置 SwipeRefreshLayout 的下拉距离
59 | mSrl.setDistanceToTriggerSync(100);
60 | //设置 SwipeRefreshLayout 正在刷新监听
61 | mSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
62 | @Override
63 | public void onRefresh() {
64 | for (int i = 0; i < 10; i++) {
65 | mData.add(0, (++number) + "");
66 | }
67 | mHandler.postDelayed(new Runnable() {
68 | @Override
69 | public void run() {
70 | mHandler.sendEmptyMessage(0);
71 | }
72 | }, 3000);
73 | }
74 | });
75 | }
76 |
77 | private void setListView() {
78 | mAdapter = new BaseAdapter() {
79 | @Override
80 | public int getCount() {
81 | return mData.size();
82 | }
83 |
84 | @Override
85 | public String getItem(int position) {
86 | return mData.get(position);
87 | }
88 |
89 | @Override
90 | public long getItemId(int position) {
91 | return position;
92 | }
93 |
94 | @Override
95 | public View getView(int position, View convertView, ViewGroup parent) {
96 | TextView tv = new TextView(parent.getContext());
97 | AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, 100);
98 | tv.setLayoutParams(params);
99 | tv.setBackgroundColor(Color.WHITE);
100 | tv.setText(getItem(position));
101 | tv.setGravity(Gravity.CENTER);
102 | return tv;
103 | }
104 | };
105 | mListView.setAdapter(mAdapter);
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/TextInputLayoutActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.design.widget.TextInputLayout;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.text.Editable;
8 | import android.text.TextWatcher;
9 |
10 | import com.lqr.materialdesigndemo.R;
11 |
12 |
13 | public class TextInputLayoutActivity extends AppCompatActivity {
14 |
15 | private TextInputLayout mTextInputLayout;
16 |
17 | @Override
18 | protected void onCreate(@Nullable Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 |
21 | setContentView(R.layout.activity_text_input_layout);
22 | mTextInputLayout = (TextInputLayout) findViewById(R.id.textInputLayout);
23 |
24 | //开启计数
25 | mTextInputLayout.setCounterEnabled(true);
26 | mTextInputLayout.setCounterMaxLength(6);
27 |
28 | //定义错误提示
29 | mTextInputLayout.getEditText().addTextChangedListener(new MyTextWatch(mTextInputLayout, "长度不能超过6个字符"));
30 | }
31 |
32 | class MyTextWatch implements TextWatcher {
33 |
34 | TextInputLayout mTextInputLayout;
35 | String mErrorTip;
36 |
37 | public MyTextWatch(TextInputLayout textInputLayout, String errorTip) {
38 | mTextInputLayout = textInputLayout;
39 | mErrorTip = errorTip;
40 | }
41 |
42 | @Override
43 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
44 |
45 | }
46 |
47 | @Override
48 | public void onTextChanged(CharSequence s, int start, int before, int count) {
49 |
50 | }
51 |
52 | @Override
53 | public void afterTextChanged(Editable s) {
54 | if (mTextInputLayout.getEditText().getText().toString().trim().length() > 6) {
55 | mTextInputLayout.setErrorEnabled(true);
56 | mTextInputLayout.setError(mErrorTip);
57 | } else {
58 | mTextInputLayout.setErrorEnabled(false);
59 | }
60 | }
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/activity/TransparentToolbarActivity.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.widget.AbsListView;
10 | import android.widget.ArrayAdapter;
11 | import android.widget.ListView;
12 |
13 | import com.lqr.materialdesigndemo.R;
14 | import com.lqr.materialdesigndemo.data.Cheeses;
15 |
16 | /**
17 | * @创建者 CSDN_LQR
18 | * @描述 仿微博上滑时Toolbar透明
19 | */
20 | public class TransparentToolbarActivity extends AppCompatActivity implements AbsListView.OnScrollListener {
21 |
22 | private Toolbar mToolbar;
23 | private ListView mLv;
24 | private int mScreenHeight;
25 |
26 | @Override
27 | protected void onCreate(@Nullable Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_transparent_toolbar);
30 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
31 | setSupportActionBar(mToolbar);
32 |
33 | mScreenHeight = getResources().getDisplayMetrics().heightPixels;
34 | Log.e("CSDN_LQR", "screenHeight = " + mScreenHeight);
35 | mLv = (ListView) findViewById(R.id.lv);
36 | mLv.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, android.R.id.text1, Cheeses.NAMES));
37 | mLv.setOnScrollListener(this);
38 | }
39 |
40 | @Override
41 | public void onScrollStateChanged(AbsListView view, int scrollState) {
42 |
43 | }
44 |
45 | @Override
46 | public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
47 | View childAt = view.getChildAt(0);
48 | if (childAt == null)
49 | return;
50 | int scrollY = firstVisibleItem * childAt.getHeight() - childAt.getTop();
51 | if (scrollY <= (mScreenHeight / 3f)) {
52 | float alpha = 1f - (scrollY / (mScreenHeight / 3f));
53 | Log.e("CSDN_LQR", "scrollY = " + scrollY);
54 | Log.e("CSDN_LQR", "alpha = " + alpha);
55 | mToolbar.setAlpha(alpha);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/adapter/ItemTouchHelperAdapter.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.adapter;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.MotionEvent;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.lqr.materialdesigndemo.R;
12 | import com.lqr.materialdesigndemo.listener.ItemDragListener;
13 | import com.lqr.materialdesigndemo.listener.ItemMoveListener;
14 |
15 | import java.util.Collections;
16 | import java.util.List;
17 |
18 | public class ItemTouchHelperAdapter extends RecyclerView.Adapter implements ItemMoveListener {
19 |
20 | private List mData;
21 | private ItemDragListener mItemDragListener;
22 |
23 | public ItemTouchHelperAdapter(List data, ItemDragListener itemDragListener) {
24 | mData = data;
25 | mItemDragListener = itemDragListener;
26 | }
27 |
28 | @Override
29 | public ItemTouchHelperViewHolder onCreateViewHolder(ViewGroup viewGroup, int position) {
30 | View itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_touch_helper, viewGroup, false);
31 | return new ItemTouchHelperViewHolder(itemView);
32 | }
33 |
34 | @Override
35 | public void onBindViewHolder(final ItemTouchHelperViewHolder viewHolder, int position) {
36 | viewHolder.mTvStr.setText(mData.get(position));
37 | viewHolder.mIvDrag.setOnTouchListener(new View.OnTouchListener() {
38 | @Override
39 | public boolean onTouch(View v, MotionEvent event) {
40 | mItemDragListener.onStartDrags(viewHolder);
41 | return false;
42 | }
43 | });
44 | }
45 |
46 | @Override
47 | public int getItemCount() {
48 | return mData.size();
49 | }
50 |
51 | @Override
52 | public boolean onItemMove(int fromPosition, int toPosition) {
53 | //1、交换数据
54 | Collections.swap(mData, fromPosition, toPosition);
55 | //2、刷新
56 | notifyItemMoved(fromPosition, toPosition);
57 | return true;
58 | }
59 |
60 | @Override
61 | public boolean onItemRemove(int position) {
62 | //1、删除数据
63 | mData.remove(position);
64 | //2、刷新
65 | notifyItemRemoved(position);
66 | return true;
67 | }
68 |
69 | class ItemTouchHelperViewHolder extends RecyclerView.ViewHolder {
70 |
71 | TextView mTvStr;
72 | ImageView mIvDrag;
73 |
74 | public ItemTouchHelperViewHolder(View itemView) {
75 | super(itemView);
76 | mTvStr = (TextView) itemView.findViewById(R.id.tvStr);
77 | mIvDrag = (ImageView) itemView.findViewById(R.id.ivDrag);
78 | }
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.adapter;
2 |
3 |
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.LinearLayout;
8 | import android.widget.TextView;
9 |
10 | import java.util.List;
11 |
12 | public class MyAdapter extends RecyclerView.Adapter {
13 |
14 | private List mData;
15 |
16 | public MyAdapter(List data) {
17 | mData = data;
18 | }
19 |
20 | @Override
21 | public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
22 | View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
23 | itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
24 | return new MyViewHolder(itemView);
25 | }
26 |
27 | @Override
28 | public void onBindViewHolder(MyViewHolder holder, int position) {
29 | holder.mTv.setText(mData.get(position));
30 | }
31 |
32 | @Override
33 | public int getItemCount() {
34 | return mData.size();
35 | }
36 |
37 | class MyViewHolder extends RecyclerView.ViewHolder {
38 |
39 | TextView mTv;
40 |
41 | public MyViewHolder(View itemView) {
42 | super(itemView);
43 | mTv = (TextView) itemView.findViewById(android.R.id.text1);
44 | }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/adapter/MyStaggeredAdapter.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.adapter;
2 |
3 |
4 | import android.graphics.Color;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | import com.lqr.materialdesigndemo.R;
12 |
13 | import java.util.List;
14 | import java.util.Random;
15 |
16 | public class MyStaggeredAdapter extends RecyclerView.Adapter {
17 |
18 | private List mData;
19 | private Random mRandom = new Random();
20 |
21 | public MyStaggeredAdapter(List data) {
22 | mData = data;
23 | }
24 |
25 | @Override
26 | public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
27 | // LayoutInflater layoutInflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
28 | // View itemView = LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_1,parent,false);
29 | View itemView = View.inflate(parent.getContext(), R.layout.item_layout, null);
30 | return new MyViewHolder(itemView);
31 | }
32 |
33 | @Override
34 | public void onBindViewHolder(MyViewHolder holder, int position) {
35 | // ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mRandom.nextInt(200) + 200);
36 | ViewGroup.LayoutParams params = holder.mTv.getLayoutParams();
37 | Log.e("CSDN_LQR", "params == null : " + (params == null));
38 | params.height = mRandom.nextInt(200) + 200;
39 | holder.mTv.setLayoutParams(params);
40 | holder.mTv.setBackgroundColor(Color.argb(255, 180 + mRandom.nextInt(60) + 30, 180 + mRandom.nextInt(60) + 30, 180 + mRandom.nextInt(60) + 30));
41 | holder.mTv.setText(mData.get(position));
42 | }
43 |
44 | @Override
45 | public int getItemCount() {
46 | return mData.size();
47 | }
48 |
49 | class MyViewHolder extends RecyclerView.ViewHolder {
50 |
51 | TextView mTv;
52 |
53 | public MyViewHolder(View itemView) {
54 | super(itemView);
55 | mTv = (TextView) itemView.findViewById(android.R.id.text1);
56 | }
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/adapter/PaletteGridAdapter.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.adapter;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.BitmapDrawable;
6 | import android.support.v7.graphics.Palette;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.ImageView;
12 | import android.widget.TextView;
13 |
14 | import com.lqr.materialdesigndemo.R;
15 | import com.lqr.materialdesigndemo.data.Cheeses;
16 |
17 | /**
18 | * @创建者 CSDN_LQR
19 | * @描述 调色板网格适配器
20 | */
21 | public class PaletteGridAdapter extends RecyclerView.Adapter {
22 |
23 | final int[] picResId = new int[]{R.mipmap.p1, R.mipmap.p2, R.mipmap.p3, R.mipmap.p4, R.mipmap.p5,
24 | R.mipmap.p6, R.mipmap.p7, R.mipmap.p8, R.mipmap.p9, R.mipmap.p10, R.mipmap.p11, R.mipmap.p12,
25 | R.mipmap.p13, R.mipmap.p14, R.mipmap.p15, R.mipmap.p16, R.mipmap.p17, R.mipmap.p18,
26 | R.mipmap.p19, R.mipmap.p20, R.mipmap.p21, R.mipmap.p22, R.mipmap.p23, R.mipmap.p24,
27 | R.mipmap.p25, R.mipmap.p26, R.mipmap.p27, R.mipmap.p28, R.mipmap.p29, R.mipmap.p30,
28 | R.mipmap.p31, R.mipmap.p32, R.mipmap.p33, R.mipmap.p34, R.mipmap.p35, R.mipmap.p36,
29 | R.mipmap.p37, R.mipmap.p38, R.mipmap.p39, R.mipmap.p40, R.mipmap.p41, R.mipmap.p42, R.mipmap.p43, R.mipmap.p44};
30 |
31 | @Override
32 | public PaletteGridViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
33 | View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_palette, parent, false);
34 | return new PaletteGridViewHolder(itemView);
35 | }
36 |
37 | @Override
38 | public void onBindViewHolder(final PaletteGridViewHolder holder, final int position) {
39 | holder.mIvPic.setImageResource(picResId[position]);
40 | BitmapDrawable bitmapDrawable = (BitmapDrawable) holder.mIvPic.getDrawable();
41 | Bitmap bitmap = bitmapDrawable.getBitmap();
42 |
43 | Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
44 | @Override
45 | public void onGenerated(Palette palette) {
46 | // 对于一张图片,它可能分析不出来暗、亮色,返回值为空,我这里采取的方案是当获取不到色调样品,则获取其他色调样品。
47 | Palette.Swatch swatch = palette.getDarkMutedSwatch();
48 | if (swatch == null) {
49 | swatch = palette.getDarkVibrantSwatch();
50 | }
51 | if (swatch == null) {
52 | swatch = palette.getLightMutedSwatch();
53 | }
54 | if (swatch == null) {
55 | swatch = palette.getLightVibrantSwatch();
56 | }
57 | if (swatch == null) {
58 | swatch = palette.getMutedSwatch();
59 | }
60 | if (swatch == null) {
61 | swatch = palette.getVibrantSwatch();
62 | }
63 | int titleTextColor = swatch.getTitleTextColor();
64 | int rgb = swatch.getRgb();
65 |
66 | holder.mTvTitle.setText(Cheeses.sCheeseStrings[position]);
67 | holder.mTvTitle.setTextColor(titleTextColor);
68 | holder.mTvTitle.setBackgroundColor(generateTransparentColor(0.5f, rgb));
69 |
70 | }
71 | });
72 | }
73 |
74 | private int generateTransparentColor(float percent, int rgb) {
75 | int red = Color.red(rgb);
76 | int green = Color.green(rgb);
77 | int blue = Color.blue(rgb);
78 | int alpha = Color.alpha(rgb);
79 | alpha = (int) (percent * alpha);
80 | return Color.argb(alpha, red, green, blue);
81 | }
82 |
83 | @Override
84 | public int getItemCount() {
85 | return picResId.length;
86 | }
87 |
88 | class PaletteGridViewHolder extends RecyclerView.ViewHolder {
89 |
90 | ImageView mIvPic;
91 | TextView mTvTitle;
92 |
93 | public PaletteGridViewHolder(View itemView) {
94 | super(itemView);
95 | mIvPic = (ImageView) itemView.findViewById(R.id.ivPic);
96 | mTvTitle = (TextView) itemView.findViewById(R.id.tvTitle);
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/behavior/CustomerBehavior1.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.behavior;
2 |
3 | import android.content.Context;
4 | import android.support.design.widget.CoordinatorLayout;
5 | import android.support.v4.view.ViewCompat;
6 | import android.util.AttributeSet;
7 | import android.view.View;
8 | import android.widget.TextView;
9 |
10 | public class CustomerBehavior1 extends CoordinatorLayout.Behavior {
11 |
12 | // 一定要重写构造函数
13 | public CustomerBehavior1(Context context, AttributeSet attrs) {
14 | super(context, attrs);
15 | }
16 |
17 | /**
18 | * 用来决定需要监听哪些控件或者容器的状态(1、知道监听谁;2、什么状态改变)
19 | *
20 | * @param parent 父容器
21 | * @param child 子控件--需要监听dependency这个view的视图们--观察者
22 | * @param dependency 你要监听的那个view
23 | */
24 | @Override
25 | public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
26 | // 还可以根据ID或者Tag来判断
27 | return dependency instanceof TextView || super.layoutDependsOn(parent, child, dependency);
28 | }
29 |
30 | /**
31 | * 当被监听的view发生改变时回调
32 | * 可以在此方法里面做一些响应的联动动画等效果
33 | */
34 | @Override
35 | public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
36 | int offset = dependency.getTop() - child.getTop();
37 | ViewCompat.offsetTopAndBottom(child, offset);
38 | return super.onDependentViewChanged(parent, child, dependency);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/behavior/CustomerBehavior2.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.behavior;
2 |
3 | import android.content.Context;
4 | import android.support.design.widget.CoordinatorLayout;
5 | import android.support.v4.view.ViewCompat;
6 | import android.support.v4.widget.NestedScrollView;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 |
10 | public class CustomerBehavior2 extends CoordinatorLayout.Behavior {
11 |
12 | public CustomerBehavior2(Context context, AttributeSet attrs) {
13 | super(context, attrs);
14 | }
15 |
16 | /**
17 | * 开始滚动前
18 | */
19 | @Override
20 | public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, View child, View target, int dx, int dy, int[] consumed) {
21 | int scrollY = target.getScrollY();
22 | child.setScrollY(scrollY);
23 | super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed);
24 | }
25 |
26 | /**
27 | * 开始滚动时
28 | */
29 | @Override
30 | public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) {
31 | // 监听竖直滚动
32 | return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL || super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
33 | }
34 |
35 | /**
36 | * 开始滚动后
37 | */
38 | @Override
39 | public void onNestedScroll(CoordinatorLayout coordinatorLayout, View child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
40 | super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
41 | }
42 |
43 | /**
44 | * 松开手指后惯性滑动之前
45 | */
46 | @Override
47 | public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, View child, View target, float velocityX, float velocityY) {
48 | return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
49 | }
50 |
51 | /**
52 | * 松开手指后惯性滑动时
53 | */
54 | @Override
55 | public boolean onNestedFling(CoordinatorLayout coordinatorLayout, View child, View target, float velocityX, float velocityY, boolean consumed) {
56 | ((NestedScrollView) child).fling((int) velocityY);
57 | return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
58 | }
59 |
60 | int count = 1;
61 |
62 | /**
63 | * 滚动结束
64 | */
65 | @Override
66 | public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, View child, View target) {
67 | child.animate().rotation(count++ * 360);
68 | super.onStopNestedScroll(coordinatorLayout, child, target);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/callback/MyItemTouchHelperCallback.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.callback;
2 |
3 | import android.graphics.Canvas;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.support.v7.widget.helper.ItemTouchHelper;
6 |
7 | import com.lqr.materialdesigndemo.listener.ItemMoveListener;
8 |
9 |
10 | public class MyItemTouchHelperCallback extends ItemTouchHelper.Callback {
11 |
12 | ItemMoveListener mItemMoveListener;
13 |
14 | public MyItemTouchHelperCallback(ItemMoveListener itemMoveListener) {
15 | mItemMoveListener = itemMoveListener;
16 | }
17 |
18 | /**
19 | * 获取动作标识
20 | * 动作标识分:dragFlags和swipeFlags
21 | * dragFlags:列表滚动方向的动作标识(如竖直列表就是上和下,水平列表就是左和右)
22 | * wipeFlags:与列表滚动方向垂直的动作标识(如竖直列表就是左和右,水平列表就是上和下)
23 | */
24 | @Override
25 | public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
26 | int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
27 | int swipeFlags = ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
28 | int flags = makeMovementFlags(dragFlags, swipeFlags);
29 | return flags;
30 | }
31 |
32 | /**
33 | * 是否开启item长按拖拽功能
34 | */
35 | @Override
36 | public boolean isLongPressDragEnabled() {
37 | return true;
38 | }
39 |
40 | /**
41 | * 当item拖拽移动时触发
42 | *
43 | * @param recyclerView
44 | * @param viewHolder 当前被拖拽的item的viewHolder
45 | * @param targetViewHolder 当前被拖拽的item下方的另一个item的viewHolder
46 | * @return
47 | */
48 | @Override
49 | public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder targetViewHolder) {
50 | return mItemMoveListener.onItemMove(viewHolder.getAdapterPosition(), targetViewHolder.getAdapterPosition());
51 | }
52 |
53 | /**
54 | * 当item侧滑出去时触发(竖直列表是侧滑,水平列表是竖滑)
55 | *
56 | * @param viewHolder
57 | * @param direction 滑动的方向
58 | */
59 | @Override
60 | public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
61 | mItemMoveListener.onItemRemove(viewHolder.getAdapterPosition());
62 | }
63 |
64 | /**
65 | * 当item被拖拽或侧滑时触发
66 | *
67 | * @param viewHolder
68 | * @param actionState 当前item的状态
69 | */
70 | @Override
71 | public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
72 | super.onSelectedChanged(viewHolder, actionState);
73 | //不管是拖拽或是侧滑,背景色都要变化
74 | if (actionState != ItemTouchHelper.ACTION_STATE_IDLE)
75 | viewHolder.itemView.setBackgroundColor(viewHolder.itemView.getContext().getResources().getColor(android.R.color.darker_gray));
76 | }
77 |
78 | /**
79 | * 当item的交互动画结束时触发
80 | *
81 | * @param recyclerView
82 | * @param viewHolder
83 | */
84 | @Override
85 | public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
86 | super.clearView(recyclerView, viewHolder);
87 | viewHolder.itemView.setBackgroundColor(viewHolder.itemView.getContext().getResources().getColor(android.R.color.white));
88 |
89 | viewHolder.itemView.setAlpha(1);
90 | viewHolder.itemView.setScaleY(1);
91 | }
92 |
93 | @Override
94 | public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
95 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
96 | if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
97 | float value = 1 - Math.abs(dX) / viewHolder.itemView.getWidth();
98 | viewHolder.itemView.setAlpha(value);
99 | viewHolder.itemView.setScaleY(value);
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationOne.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.decoration;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Rect;
7 | import android.graphics.drawable.Drawable;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 |
11 | /**
12 | * @创建者 CSDN_LQR
13 | * @描述 自定义条目装饰(不仅仅是分割线)
14 | */
15 | public class MyDecorationOne extends RecyclerView.ItemDecoration {
16 |
17 | int orientation = RecyclerView.HORIZONTAL;
18 | private final Drawable mDivider;
19 |
20 | public MyDecorationOne(Context context, int orientation) {
21 | this.orientation = orientation;
22 | int[] attrs = new int[]{android.R.attr.listDivider};
23 | TypedArray a = context.obtainStyledAttributes(attrs);
24 | mDivider = a.getDrawable(0);
25 | a.recycle();
26 | }
27 |
28 | /**
29 | * 画线
30 | */
31 | @Override
32 | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
33 | super.onDraw(c, parent, state);
34 | if (orientation == RecyclerView.HORIZONTAL) {
35 | drawVertical(c, parent, state);
36 | } else if (orientation == RecyclerView.VERTICAL) {
37 | drawHorizontal(c, parent, state);
38 | }
39 | }
40 |
41 | private void drawVertical(Canvas c, RecyclerView parent, RecyclerView.State state) {
42 | int childCount = parent.getChildCount();
43 | for (int i = 0; i < childCount; i++) {
44 | View child = parent.getChildAt(i);
45 | RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
46 | int left = child.getRight() + params.rightMargin;
47 | int top = child.getTop() - params.topMargin;
48 | int right = left + mDivider.getIntrinsicWidth();
49 | int bottom = child.getBottom() + params.bottomMargin;
50 | mDivider.setBounds(left, top, right, bottom);
51 | mDivider.draw(c);
52 | }
53 | }
54 |
55 | private void drawHorizontal(Canvas c, RecyclerView parent, RecyclerView.State state) {
56 | int childCount = parent.getChildCount();
57 | for (int i = 0; i < childCount; i++) {
58 | View child = parent.getChildAt(i);
59 | RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
60 | int left = child.getLeft() - params.leftMargin;
61 | int top = child.getBottom() + params.bottomMargin;
62 | int right = child.getRight() + params.rightMargin;
63 | int bottom = top + mDivider.getIntrinsicHeight();
64 | mDivider.setBounds(left, top, right, bottom);
65 | mDivider.draw(c);
66 | }
67 | }
68 |
69 |
70 | /**
71 | * 设置条目周边的偏移量
72 | */
73 | @Override
74 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
75 | super.getItemOffsets(outRect, view, parent, state);
76 | if (orientation == RecyclerView.HORIZONTAL) {
77 | //画垂直线
78 | outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
79 | } else if (orientation == RecyclerView.VERTICAL) {
80 | //画水平线
81 | outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationThree.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.decoration;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.Rect;
8 | import android.support.v7.widget.LinearLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.util.TypedValue;
11 | import android.view.View;
12 |
13 | import com.lqr.materialdesigndemo.utils.PinyinUtils;
14 |
15 | import java.util.List;
16 |
17 |
18 | public class MyDecorationThree extends RecyclerView.ItemDecoration {
19 |
20 | Context mContext;
21 | List mData;
22 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
23 |
24 |
25 | public MyDecorationThree(Context context, List data) {
26 | mContext = context;
27 | mData = data;
28 | paint.setTextSize(sp2px(16));
29 | paint.setColor(Color.RED);
30 | }
31 |
32 | @Override
33 | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
34 | super.onDraw(c, parent, state);
35 | drawLetterToItemLeft(c, parent);
36 | }
37 |
38 | private void drawLetterToItemLeft(Canvas c, RecyclerView parent) {
39 | RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
40 | if (!(layoutManager instanceof LinearLayoutManager))
41 | return;
42 | int childCount = parent.getChildCount();
43 | for (int i = 0; i < childCount; i++) {
44 | int position = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition() + i;
45 | View child = parent.getChildAt(i);
46 | RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
47 | float left = 0;
48 | float top = child.getTop() - params.topMargin;
49 | float right = child.getLeft() - params.leftMargin;
50 | float bottom = child.getBottom() + params.bottomMargin;
51 | float width = right - left;
52 | float height = bottom - (bottom - top) / 2;
53 | //当前名字拼音的第一个字母
54 | String letter = PinyinUtils.getPinyin(mData.get(position)).charAt(0) + "";
55 | if (position == 0) {
56 | drawLetter(letter, width, height, c, parent);
57 | } else {
58 | String preLetter = PinyinUtils.getPinyin(mData.get(position - 1)).charAt(0) + "";
59 | if (!letter.equalsIgnoreCase(preLetter)) {
60 | drawLetter(letter, width, height, c, parent);
61 | }
62 | }
63 | }
64 | }
65 |
66 | private void drawLetter(String letter, float width, float height, Canvas c, RecyclerView parent) {
67 | float fontLength = getFontLength(paint, letter);
68 | float fontHeight = getFontHeight(paint);
69 | float tx = (width - fontLength) / 2;
70 | float ty = height - fontHeight / 2 + getFontLeading(paint);
71 | c.drawText(letter, tx, ty, paint);
72 | }
73 |
74 | @Override
75 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
76 | super.getItemOffsets(outRect, view, parent, state);
77 | outRect.set(dip2px(40), 0, 0, 0);
78 | }
79 |
80 | private int dip2px(int dip) {
81 | float density = mContext.getResources().getDisplayMetrics().density;
82 | int px = (int) (dip * density + 0.5f);
83 | return px;
84 | }
85 |
86 | public int sp2px(int sp) {
87 | return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, mContext.getResources().getDisplayMetrics()) + 0.5f);
88 | }
89 |
90 |
91 | /**
92 | * 返回指定笔和指定字符串的长度
93 | */
94 | private float getFontLength(Paint paint, String str) {
95 | return paint.measureText(str);
96 | }
97 |
98 | /**
99 | * 返回指定笔的文字高度
100 | */
101 | private float getFontHeight(Paint paint) {
102 | Paint.FontMetrics fm = paint.getFontMetrics();
103 | return fm.descent - fm.ascent;
104 | }
105 |
106 |
107 | /**
108 | * 返回指定笔离文字顶部的基准距离
109 | */
110 | private float getFontLeading(Paint paint) {
111 | Paint.FontMetrics fm = paint.getFontMetrics();
112 | return fm.leading - fm.ascent;
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationTwo.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.decoration;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Rect;
6 | import android.graphics.drawable.Drawable;
7 | import android.support.v7.widget.GridLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 |
11 | import com.lqr.materialdesigndemo.R;
12 |
13 |
14 | public class MyDecorationTwo extends RecyclerView.ItemDecoration {
15 |
16 | private final Drawable mDivider;
17 |
18 | public MyDecorationTwo(Context context) {
19 | // int attrs[] = new int[]{android.R.attr.listDivider};
20 | // TypedArray a = context.obtainStyledAttributes(attrs);
21 | // mDivider = a.getDrawable(0);
22 | // a.recycle();
23 |
24 | mDivider = context.getResources().getDrawable(R.drawable.divider);
25 | }
26 |
27 | @Override
28 | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
29 | super.onDraw(c, parent, state);
30 | drawVertical(c, parent);
31 | drawHorizontal(c, parent);
32 | }
33 |
34 | private void drawVertical(Canvas c, RecyclerView parent) {
35 | int childCount = parent.getChildCount();
36 | for (int i = 0; i < childCount; i++) {
37 | View child = parent.getChildAt(i);
38 | RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
39 | int left = child.getRight() + params.rightMargin;
40 | int top = child.getTop() - params.topMargin;
41 | int right = left + mDivider.getIntrinsicWidth();
42 | int bottom = child.getBottom() + params.bottomMargin;
43 | mDivider.setBounds(left, top, right, bottom);
44 | mDivider.draw(c);
45 | }
46 | }
47 |
48 | private void drawHorizontal(Canvas c, RecyclerView parent) {
49 | int childCount = parent.getChildCount();
50 | for (int i = 0; i < childCount; i++) {
51 | View child = parent.getChildAt(i);
52 | RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
53 | int left = child.getLeft() - params.leftMargin;
54 | int top = child.getBottom() + params.bottomMargin;
55 | int right = child.getRight() + params.rightMargin;
56 | int bottom = top + mDivider.getMinimumHeight();
57 | mDivider.setBounds(left, top, right, bottom);
58 | mDivider.draw(c);
59 | }
60 | }
61 |
62 | @Override
63 | public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
64 | super.getItemOffsets(outRect, itemPosition, parent);
65 | int right = mDivider.getIntrinsicWidth();
66 | int bottom = mDivider.getIntrinsicHeight();
67 |
68 | if (isLastSpan(itemPosition, parent)) {
69 | right = 0;
70 | }
71 |
72 | if (isLastRow(itemPosition, parent)) {
73 | bottom = 0;
74 | }
75 | outRect.set(0, 0, right, bottom);
76 | }
77 |
78 | // @Override
79 | // public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
80 | // super.getItemOffsets(outRect, view, parent, state);
81 | // outRect.set(0, 0, mDivider.getIntrinsicWidth(), mDivider.getIntrinsicHeight());
82 | // }
83 |
84 | public boolean isLastRow(int itemPosition, RecyclerView parent) {
85 | RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
86 | if (layoutManager instanceof GridLayoutManager) {
87 | int spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
88 | int itemCount = parent.getAdapter().getItemCount();
89 | if ((itemCount - itemPosition - 1) < spanCount)
90 | return true;
91 | }
92 | return false;
93 | }
94 |
95 | public boolean isLastSpan(int itemPosition, RecyclerView parent) {
96 | RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
97 | if (layoutManager instanceof GridLayoutManager) {
98 | int spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
99 | if ((itemPosition + 1) % spanCount == 0)
100 | return true;
101 | }
102 | return false;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/fragment/TextFragment.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | /**
12 | * @创建者 CSDN_LQR
13 | * @描述 只有一个文本控件的Fragment
14 | */
15 | public class TextFragment extends Fragment {
16 | @Nullable
17 | @Override
18 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
19 | TextView textView = new TextView(getContext());
20 | Bundle bundle = getArguments();
21 | String title = (String) bundle.get("title");
22 | textView.setText(title);
23 | return textView;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/listener/FakeFabActionListner.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.listener;
2 |
3 | public interface FakeFabActionListner {
4 |
5 | void hide();
6 |
7 | void show();
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/listener/FakeFabScrollListener.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.listener;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 |
5 | /**
6 | * @创建者 CSDN_LQR
7 | * @描述 仿Fab与RecyclerView的交互动画的RecyclerView滚动监听
8 | */
9 | public class FakeFabScrollListener extends RecyclerView.OnScrollListener {
10 |
11 | private static final int THRESHOLD = 20;
12 | private int distance = 0;
13 | private boolean visiable = true;
14 | private FakeFabActionListner mFakeFabActionListner;
15 |
16 | public FakeFabScrollListener(FakeFabActionListner fakeFabActionListner) {
17 | mFakeFabActionListner = fakeFabActionListner;
18 | }
19 |
20 | @Override
21 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
22 | super.onScrolled(recyclerView, dx, dy);
23 | if (distance > THRESHOLD && visiable) {
24 | // 隐藏
25 | distance = 0;
26 | visiable = false;
27 | if (mFakeFabActionListner != null)
28 | mFakeFabActionListner.hide();
29 | } else if (distance < -THRESHOLD && !visiable) {
30 | // 显示
31 | distance = 0;
32 | visiable = true;
33 | if (mFakeFabActionListner != null)
34 | mFakeFabActionListner.show();
35 | }
36 | if (visiable && dy > 0 || (!visiable) && dy < 0)
37 | distance += dy;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/listener/ItemDragListener.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.listener;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 |
5 |
6 | public interface ItemDragListener {
7 | void onStartDrags(RecyclerView.ViewHolder viewHolder);
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/listener/ItemMoveListener.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.listener;
2 |
3 | public interface ItemMoveListener {
4 | boolean onItemMove(int fromPosition, int toPosition);
5 |
6 | boolean onItemRemove(int position);
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/lqr/materialdesigndemo/utils/PinyinUtils.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo.utils;
2 |
3 | import net.sourceforge.pinyin4j.PinyinHelper;
4 | import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
5 | import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
6 | import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
7 | import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
8 |
9 | /**
10 | * @创建者 CSDN_LQR
11 | * @描述 拼音工具(需要pinyin4j-2.5.0.jar)
12 | */
13 | public class PinyinUtils {
14 |
15 | /**
16 | * 根据传入的字符串(包含汉字),得到拼音
17 | * 沧晓 -> CANGXIAO
18 | * 沧 晓*& -> CANGXIAO
19 | * 沧晓f5 -> CANGXIAO
20 | *
21 | * @param str 字符串
22 | * @return
23 | */
24 | public static String getPinyin(String str) {
25 |
26 | HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
27 | format.setCaseType(HanyuPinyinCaseType.UPPERCASE);
28 | format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
29 |
30 | StringBuilder sb = new StringBuilder();
31 |
32 | char[] charArray = str.toCharArray();
33 | for (int i = 0; i < charArray.length; i++) {
34 | char c = charArray[i];
35 | // 如果是空格, 跳过
36 | if (Character.isWhitespace(c)) {
37 | continue;
38 | }
39 | if (c >= -127 && c < 128 || !(c >= 0x4E00 && c <= 0x9FA5)) {
40 | // 肯定不是汉字
41 | sb.append(c);
42 | } else {
43 | String s = "";
44 | try {
45 | // 通过char得到拼音集合. 单 -> dan, shan
46 | s = PinyinHelper.toHanyuPinyinStringArray(c, format)[0];
47 | sb.append(s);
48 | } catch (BadHanyuPinyinOutputFormatCombination e) {
49 | e.printStackTrace();
50 | sb.append(s);
51 | }
52 | }
53 | }
54 |
55 | return sb.toString();
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cardview_z_translation.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
10 |
11 | -
12 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/divider_vertical.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/line.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_fake_fab.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 | -
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_android_5_new_features.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
17 |
18 |
22 |
23 |
28 |
29 |
34 |
35 |
36 |
37 |
42 |
43 |
47 |
48 |
53 |
54 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_applayout1.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
19 |
20 |
21 |
22 |
26 |
27 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_applayout2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
19 |
20 |
21 |
22 |
26 |
27 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_applayout3.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
20 |
21 |
22 |
23 |
27 |
28 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_applayout4.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
20 |
21 |
22 |
23 |
27 |
28 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_applayout5.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
20 |
21 |
22 |
23 |
27 |
28 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_applayout6.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
22 |
23 |
29 |
30 |
37 |
38 |
39 |
40 |
44 |
45 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_behavior1.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
16 |
17 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_card_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_fake_fab_interactive.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
22 |
23 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_floating_action_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_immersive.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
20 |
21 |
25 |
26 |
30 |
31 |
35 |
36 |
40 |
41 |
45 |
46 |
50 |
51 |
55 |
56 |
60 |
61 |
65 |
66 |
70 |
71 |
75 |
76 |
80 |
81 |
85 |
86 |
90 |
91 |
95 |
96 |
97 |
98 |
102 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_linear_layout_compat.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
20 |
21 |
28 |
29 |
36 |
37 |
38 |
39 |
43 |
44 |
51 |
52 |
59 |
60 |
61 |
62 |
63 |
71 |
72 |
76 |
77 |
81 |
82 |
86 |
87 |
91 |
92 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_list_popup_window.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_object_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_object_animation2.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
21 |
22 |
23 |
24 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_palette.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
17 |
18 |
26 |
27 |
36 |
37 |
38 |
46 |
47 |
55 |
56 |
64 |
65 |
73 |
74 |
82 |
83 |
91 |
92 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_palette2.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_popup_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_search_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_search_view2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
20 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_swipe_refresh_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_tab_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_text_input_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
20 |
21 |
22 |
23 |
30 |
31 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_transparent_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
29 |
30 |
37 |
38 |
43 |
44 |
49 |
50 |
56 |
57 |
62 |
63 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_palette.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_touch_helper.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/lqr_search_view.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
18 |
19 |
27 |
28 |
37 |
38 |
46 |
47 |
48 |
55 |
56 |
73 |
74 |
84 |
85 |
86 |
87 |
92 |
93 |
104 |
105 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/search_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_add_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/ic_add_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_drag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/ic_drag.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/icon_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/icon_1.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/icon_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/icon_2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p1.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p10.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p10.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p11.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p12.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p13.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p13.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p14.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p14.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p15.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p15.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p16.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p16.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p17.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p17.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p18.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p18.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p19.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p19.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p2.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p20.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p20.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p21.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p21.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p22.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p22.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p23.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p23.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p24.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p24.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p25.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p25.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p26.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p26.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p27.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p27.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p28.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p28.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p29.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p29.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p3.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p30.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p30.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p31.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p31.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p32.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p32.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p33.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p33.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p34.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p34.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p35.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p35.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p36.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p36.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p37.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p37.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p38.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p38.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p39.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p39.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p4.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p40.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p40.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p41.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p41.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p42.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p42.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p43.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p43.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p44.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p44.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p5.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p6.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p7.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p8.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/p9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/p9.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/palette.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-hdpi/palette.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/lg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-xxhdpi/lg.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/lq.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-xxhdpi/lq.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/lt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-xxhdpi/lt.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/lv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-xxhdpi/lv.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/lw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-xxhdpi/lw.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/m5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-xxhdpi/m5.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #F00
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 0dp
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MaterialDesignDemo
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
21 |
22 |
26 |
27 |
28 |
38 |
39 |
44 |
45 |
46 |
50 |
51 |
52 |
55 |
56 |
57 |
61 |
62 |
63 |
67 |
68 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/app/src/test/java/com/lqr/materialdesigndemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.lqr.materialdesigndemo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Apr 22 18:53:59 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/screenshots/1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/screenshots/1.gif
--------------------------------------------------------------------------------
/screenshots/2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/screenshots/2.gif
--------------------------------------------------------------------------------
/screenshots/3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/screenshots/3.gif
--------------------------------------------------------------------------------
/screenshots/4.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/screenshots/4.gif
--------------------------------------------------------------------------------
/screenshots/5.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitLqr/MaterialDesignDemo/e361f094255df2c20e74d5773a55882ec99d5a73/screenshots/5.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------