├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── four.jpg
│ │ │ │ ├── one.jpg
│ │ │ │ ├── two.jpg
│ │ │ │ ├── three.jpg
│ │ │ │ ├── top_bg.jpg
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable
│ │ │ │ ├── ic_back_black.xml
│ │ │ │ ├── ic_touch_tag.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── activity_coordinator_layout1.xml
│ │ │ │ ├── activity_transparent.xml
│ │ │ │ ├── activity_toolbar.xml
│ │ │ │ └── activity_behavior.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── stone
│ │ │ │ └── view
│ │ │ │ ├── ToolBarDemoActivity.java
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── SampleTitleBehavior.java
│ │ │ │ ├── BehaviorActivity.java
│ │ │ │ ├── TransparentActivity.kt
│ │ │ │ ├── StatusBarUtils.java
│ │ │ │ └── AppBarBehavior.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── stone
│ │ │ └── view
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── stone
│ │ └── view
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── compiler.xml
├── vcs.xml
├── runConfigurations.xml
├── gradle.xml
├── assetWizardSettings.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── jarRepositories.xml
├── codeStyles
│ └── Project.xml
└── misc.xml
├── .gitignore
├── gradle.properties
├── LICENSE
├── gradlew.bat
├── gradlew
└── README.md
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/four.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-xxhdpi/four.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/one.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-xxhdpi/one.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/two.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-xxhdpi/two.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/three.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-xxhdpi/three.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/top_bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-xxhdpi/top_bg.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JR-Stone/JR-CoordinatorLayout/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches/build_file_checksums.ser
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | .DS_Store
9 | /build
10 | /captures
11 | .externalNativeBuild
12 |
13 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jan 21 13:49:44 CST 2021
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-6.5-bin.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 | #FFF
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | JR-View
3 | com.stone.view.AppBarBehavior
4 | 一个神秘的网站
5 | com.stone.view.SampleTitleBehavior
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 450dp
4 | 10dp
5 | 80dp
6 | 40dp
7 | 23sp
8 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_back_black.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/test/java/com/stone/view/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.stone.view;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/stone/view/ToolBarDemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.stone.view;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 |
6 | import androidx.appcompat.app.AppCompatActivity;
7 |
8 | public class ToolBarDemoActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_toolbar);
14 | findViewById(R.id.title).setOnClickListener(new View.OnClickListener() {
15 | @Override
16 | public void onClick(View v) {
17 | finish();
18 | }
19 | });
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/stone/view/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.stone.view
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import android.view.View
6 | import androidx.appcompat.app.AppCompatActivity
7 |
8 | class MainActivity : AppCompatActivity() {
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.activity_main)
12 | }
13 |
14 | fun behaviorIntent(view:View) {
15 | startActivity(Intent(this,BehaviorActivity::class.java))
16 | }
17 | fun toolBarIntent(view: View){
18 | startActivity(Intent(this,ToolBarDemoActivity::class.java))
19 | }
20 | fun transparentIntent(view: View){
21 | startActivity(Intent(this,TransparentActivity::class.java))
22 | }
23 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | android.useAndroidX=true
15 | android.enableJetifier=true
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/stone/view/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.stone.view;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.stone.view", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Stone
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 |
--------------------------------------------------------------------------------
/.idea/assetWizardSettings.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 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
25 |
26 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/stone/view/SampleTitleBehavior.java:
--------------------------------------------------------------------------------
1 | package com.stone.view;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 |
7 | import androidx.coordinatorlayout.widget.CoordinatorLayout;
8 | import androidx.core.widget.NestedScrollView;
9 |
10 | public class SampleTitleBehavior extends CoordinatorLayout.Behavior {
11 | // 列表顶部和title底部重合时,列表的滑动距离。
12 | private float deltaY;
13 |
14 | public SampleTitleBehavior() {
15 | }
16 |
17 | public SampleTitleBehavior(Context context, AttributeSet attrs) {
18 | super(context, attrs);
19 | }
20 |
21 | @Override
22 | public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
23 | return dependency instanceof NestedScrollView;
24 | }
25 |
26 | /**
27 | * child: 使用behavior的目标view及这里的TextView
28 | * dependency: 指要监听的view及这里的 RecyclerView*/
29 | @Override
30 | public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
31 | if (deltaY == 0) {
32 | deltaY = dependency.getY() - child.getHeight();
33 | }
34 | float dy = dependency.getY() - child.getHeight();
35 | dy = dy < 0 ? 0 : dy;
36 | float y = -(dy / deltaY) * child.getHeight();
37 | child.setTranslationY(y);
38 |
39 | return true;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.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 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_touch_tag.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | compileSdkVersion 30
6 | defaultConfig {
7 | applicationId "com.stone.view"
8 | minSdkVersion 21
9 | targetSdkVersion 30
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 |
21 | dataBinding {
22 | enabled = true
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 | implementation 'androidx.appcompat:appcompat:1.1.0'
29 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
30 | testImplementation 'junit:junit:4.12'
31 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
32 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
33 |
34 | //Google Material控件,以及迁移到AndroidX下一些控件的依赖
35 | implementation 'com.google.android.material:material:1.0.0'
36 | //图片加载框架
37 | implementation 'com.github.bumptech.glide:glide:4.10.0'
38 | annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
39 | implementation "androidx.core:core-ktx:+"
40 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
41 |
42 | /*高德地图*/
43 | implementation 'com.amap.api:3dmap:latest.integration'
44 | implementation 'com.amap.api:location:latest.integration'
45 | implementation 'com.amap.api:search:latest.integration'
46 | }
47 | repositories {
48 | maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
49 | mavenCentral()
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.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 |
--------------------------------------------------------------------------------
/app/src/main/java/com/stone/view/BehaviorActivity.java:
--------------------------------------------------------------------------------
1 | package com.stone.view;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 |
6 | import androidx.appcompat.app.AppCompatActivity;
7 | import androidx.appcompat.widget.Toolbar;
8 | import androidx.coordinatorlayout.widget.CoordinatorLayout;
9 | import androidx.core.widget.NestedScrollView;
10 |
11 | import com.amap.api.maps.AMap;
12 | import com.amap.api.maps.MapView;
13 | import com.google.android.material.appbar.AppBarLayout;
14 |
15 | /**
16 | * @author nnr
17 | */
18 | public class BehaviorActivity extends AppCompatActivity {
19 | AppBarLayout appBarLayout;
20 | NestedScrollView scrollView;
21 | MapView mapView;
22 |
23 | private CoordinatorLayout.LayoutParams layoutParams;
24 | private AMap aMap;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_behavior);
30 | appBarLayout = findViewById(R.id.appBar);
31 | scrollView = findViewById(R.id.nestScrollView);
32 | mapView = findViewById(R.id.mapView);
33 | mapView.onCreate(savedInstanceState);
34 | if (aMap == null) {
35 | aMap = mapView.getMap();
36 | }
37 | layoutParams = (CoordinatorLayout.LayoutParams) scrollView.getLayoutParams();
38 | layoutParams.setMargins(30, 0, 30, 0);
39 | scrollView.setLayoutParams(layoutParams);
40 | appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
41 | @Override
42 | public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
43 | float a = (float) 30 / appBarLayout.getTotalScrollRange();
44 | int side = (int) Math.rint(a * i + 30);
45 | layoutParams.setMargins(side, 0, side, 0);
46 | scrollView.setLayoutParams(layoutParams);
47 | if (Math.abs(i) > 0) {
48 | float alpha = (float) Math.abs(i) / appBarLayout.getTotalScrollRange();
49 | appBarLayout.setAlpha(alpha);
50 | scrollView.getBackground().mutate().setAlpha(Math.round(alpha * 255));
51 | } else {
52 | appBarLayout.setAlpha(0);
53 | scrollView.getBackground().mutate().setAlpha(0);
54 | }
55 | }
56 | });
57 | ((Toolbar)findViewById(R.id.toolbar)).setNavigationOnClickListener(new View.OnClickListener() {
58 | @Override
59 | public void onClick(View v) {
60 | finish();
61 | }
62 | });
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/com/stone/view/TransparentActivity.kt:
--------------------------------------------------------------------------------
1 | package com.stone.view
2 |
3 | import android.graphics.Color
4 | import androidx.appcompat.app.AppCompatActivity
5 | import android.os.Bundle
6 | import androidx.databinding.DataBindingUtil
7 | import com.bumptech.glide.Glide
8 | import com.google.android.material.appbar.AppBarLayout
9 | import com.stone.view.databinding.ActivityTransparentBinding
10 | import kotlin.math.abs
11 |
12 | class TransparentActivity : AppCompatActivity() {
13 |
14 | lateinit var baseBinding: ActivityTransparentBinding
15 | override fun onCreate(savedInstanceState: Bundle?) {
16 | super.onCreate(savedInstanceState)
17 | setContentView(R.layout.activity_transparent)
18 | initView()
19 | showImg()//显示图片
20 | }
21 |
22 | /**
23 | * 初始化视图
24 | */
25 | private fun initView() {
26 | //绑定视图
27 | baseBinding = DataBindingUtil.setContentView(this, R.layout.activity_transparent)
28 | //透明状态栏
29 | StatusBarUtils.setImmersionStateMode(this)
30 | //滑动偏移监听事件
31 | baseBinding.appbar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset ->
32 | val toolbarHeight = appBarLayout.totalScrollRange
33 | val dy = abs(verticalOffset)
34 | if (dy <= toolbarHeight) {
35 | val than = dy.toFloat() / toolbarHeight
36 | val alpha = than * 255
37 | //文字颜色透明度
38 | baseBinding.title.setTextColor(Color.argb(alpha.toInt(), 0, 0, 0))
39 | //背景透明度
40 | baseBinding.toolBarLl.setBackgroundColor(Color.argb(alpha.toInt(), 255, 255, 255))
41 | }
42 | })
43 |
44 | baseBinding.title.setOnClickListener{
45 | finish()
46 | }
47 | }
48 |
49 | /**
50 | * 使用Glide加载显示网络图片 记得加网络权限和http地址url访问许可
51 | */
52 | private fun showImg() {
53 | Glide.with(this)
54 | .load("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fdingyue.nosdn.127.net%2FtFpW5np6B29BdKoNqVrXngVtDBXrRDWkjTpo6dC31fdTk1556418127777compressflag.jpeg&refer=http%3A%2F%2Fdingyue.nosdn.127.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1613799018&t=06901b31235a677ea90a1e893c870880")
55 | .into(baseBinding.one)
56 | Glide.with(this)
57 | .load("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhiphotos.baidu.com%2Fzhidao%2Fpic%2Fitem%2Ff603918fa0ec08fa6443cb2657ee3d6d54fbdaf4.jpg&refer=http%3A%2F%2Fhiphotos.baidu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1613799018&t=73365e7c6796f84f339c8d128b51fb14")
58 | .into(baseBinding.two)
59 | Glide.with(this)
60 | .load("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic2.zhimg.com%2F50%2Fv2-79d594594fdd7441e848d3da749751de_hd.jpg&refer=http%3A%2F%2Fpic2.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1613799018&t=dd9c98afb4644677a9d51ed1204ea51a")
61 | .into(baseBinding.three)
62 | Glide.with(this)
63 | .load("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimage11.m1905.cn%2Fuploadfile%2F2009%2F0910%2F195%2F20090910034058548.jpg&refer=http%3A%2F%2Fimage11.m1905.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1613799018&t=276c48498abbcacc362917717bbbd38c")
64 | .into(baseBinding.four)
65 | Glide.with(this)
66 | .load("https://ss2.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/dcc451da81cb39db0b2d4545d6160924ab183037.jpg")
67 | .into(baseBinding.five)
68 | }
69 | }
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | xmlns:android
11 |
12 | ^$
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | xmlns:.*
22 |
23 | ^$
24 |
25 |
26 | BY_NAME
27 |
28 |
29 |
30 |
31 |
32 |
33 | .*:id
34 |
35 | http://schemas.android.com/apk/res/android
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | .*:name
45 |
46 | http://schemas.android.com/apk/res/android
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | name
56 |
57 | ^$
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | style
67 |
68 | ^$
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | .*
78 |
79 | ^$
80 |
81 |
82 | BY_NAME
83 |
84 |
85 |
86 |
87 |
88 |
89 | .*
90 |
91 | http://schemas.android.com/apk/res/android
92 |
93 |
94 | ANDROID_ATTRIBUTE_ORDER
95 |
96 |
97 |
98 |
99 |
100 |
101 | .*
102 |
103 | .*
104 |
105 |
106 | BY_NAME
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_coordinator_layout1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
15 |
16 |
22 |
23 |
30 |
31 |
39 |
40 |
41 |
42 |
43 |
51 |
52 |
59 |
60 |
65 |
70 |
71 |
72 |
77 |
78 |
83 |
88 |
93 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/.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 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_transparent.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
15 |
19 |
20 |
24 |
25 |
30 |
31 |
32 |
37 |
38 |
45 |
46 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
70 |
71 |
75 |
76 |
81 |
82 |
87 |
88 |
93 |
94 |
99 |
100 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/app/src/main/java/com/stone/view/StatusBarUtils.java:
--------------------------------------------------------------------------------
1 | package com.stone.view;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.graphics.Color;
6 | import android.os.Build;
7 | import android.view.View;
8 | import android.view.Window;
9 | import android.view.WindowManager;
10 |
11 | import java.lang.reflect.Field;
12 | import java.lang.reflect.Method;
13 |
14 | public class StatusBarUtils {
15 |
16 | /**
17 | * 兼容状态栏透明(沉浸式)
18 | *
19 | * @param activity
20 | */
21 | public static void setImmersionStateMode(Activity activity) {
22 | StatusBarLightMode(activity);
23 | transparentStatusBar(activity);
24 | }
25 |
26 | /**
27 | * 使状态栏透明
28 | */
29 | @TargetApi(Build.VERSION_CODES.KITKAT)
30 | private static void transparentStatusBar(Activity activity) {
31 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
32 | activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
33 | activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
34 | //需要设置这个flag contentView才能延伸到状态栏
35 | activity.getWindow().setNavigationBarColor(Color.TRANSPARENT);
36 | //状态栏覆盖在contentView上面,设置透明使contentView的背景透出来
37 | } else {
38 | //让contentView延伸到状态栏并且设置状态栏颜色透明
39 | }
40 | activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
41 | }
42 |
43 | /**
44 | * 设置状态栏黑色字体图标,
45 | * 适配4.4以上版本MIUIV、Flyme和6.0以上版本其他Android
46 | *
47 | * @param activity
48 | * @return 1:MIUUI 2:Flyme 3:android6.0
49 | */
50 | public static int StatusBarLightMode(Activity activity) {
51 | int result = 0;
52 | if (MIUISetStatusBarLightMode(activity.getWindow(), true)) {
53 | result = 1;
54 | } else if (FlymeSetStatusBarLightMode(activity.getWindow(), true)) {
55 | result = 2;
56 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
57 | activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
58 | result = 3;
59 | }
60 | return result;
61 | }
62 |
63 | /**
64 | * 设置状态栏图标为深色和魅族特定的文字风格
65 | * 可以用来判断是否为Flyme用户
66 | *
67 | * @param window 需要设置的窗口
68 | * @param dark 是否把状态栏字体及图标颜色设置为深色
69 | * @return boolean 成功执行返回true
70 | */
71 | public static boolean FlymeSetStatusBarLightMode(Window window, boolean dark) {
72 | boolean result = false;
73 | if (window != null) {
74 | try {
75 | WindowManager.LayoutParams lp = window.getAttributes();
76 | Field darkFlag = WindowManager.LayoutParams.class
77 | .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
78 | Field meizuFlags = WindowManager.LayoutParams.class
79 | .getDeclaredField("meizuFlags");
80 | darkFlag.setAccessible(true);
81 | meizuFlags.setAccessible(true);
82 | int bit = darkFlag.getInt(null);
83 | int value = meizuFlags.getInt(lp);
84 | if (dark) {
85 | value |= bit;
86 | } else {
87 | value &= ~bit;
88 | }
89 | meizuFlags.setInt(lp, value);
90 | window.setAttributes(lp);
91 | result = true;
92 | } catch (Exception e) {
93 |
94 | }
95 | }
96 | return result;
97 | }
98 |
99 | /**
100 | * 设置状态栏字体图标为深色,需要MIUIV6以上
101 | *
102 | * @param window 需要设置的窗口
103 | * @param dark 是否把状态栏字体及图标颜色设置为深色
104 | * @return boolean 成功执行返回true
105 | */
106 | public static boolean MIUISetStatusBarLightMode(Window window, boolean dark) {
107 | boolean result = false;
108 | if (window != null) {
109 | Class clazz = window.getClass();
110 | try {
111 | int darkModeFlag = 0;
112 | Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
113 | Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
114 | darkModeFlag = field.getInt(layoutParams);
115 | Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
116 | if (dark) {
117 | extraFlagField.invoke(window, darkModeFlag, darkModeFlag);//状态栏透明且黑色字体
118 | } else {
119 | extraFlagField.invoke(window, 0, darkModeFlag);//清除黑色字体
120 | }
121 | result = true;
122 | } catch (Exception e) {
123 |
124 | }
125 | }
126 | return result;
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
20 |
21 |
29 |
30 |
31 |
32 |
33 |
41 |
42 |
48 |
49 |
57 |
58 |
63 |
68 |
69 |
70 |
75 |
76 |
81 |
86 |
91 |
96 |
101 |
102 |
103 |
104 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_behavior.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
28 |
29 |
36 |
37 |
38 |
39 |
40 |
48 |
49 |
55 |
56 |
64 |
65 |
70 |
107 |
108 |
109 |
110 |
118 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/java/com/stone/view/AppBarBehavior.java:
--------------------------------------------------------------------------------
1 | package com.stone.view;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.MotionEvent;
6 | import android.view.View;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.coordinatorlayout.widget.CoordinatorLayout;
10 | import androidx.core.view.ViewCompat;
11 |
12 | import com.google.android.material.appbar.AppBarLayout;
13 |
14 | public class AppBarBehavior extends AppBarLayout.Behavior {
15 | /**
16 | * nestedScrollview的滑动距离
17 | */
18 | int ay = 0;
19 | /**
20 | * nestedScrollview 沒有滑动到顶部之前的可滑动最大距离
21 | */
22 | private int minY = 0;
23 |
24 | public AppBarBehavior() {
25 |
26 | }
27 |
28 | public AppBarBehavior(Context context, AttributeSet attrs) {
29 | super(context, attrs);
30 | }
31 |
32 | /**
33 | * AppBarLayout布局时调用
34 | *
35 | * @param parent 父布局CoordinatorLayout
36 | * @param abl 使用此Behavior的AppBarLayout
37 | * @param layoutDirection 布局方向
38 | * @return 返回true表示子View重新布局,返回false表示请求默认布局
39 | */
40 | @Override
41 | public boolean onLayoutChild(CoordinatorLayout parent, AppBarLayout abl, int layoutDirection) {
42 | return super.onLayoutChild(parent, abl, layoutDirection);
43 | }
44 |
45 | /**
46 | * 当CoordinatorLayout的子View尝试发起嵌套滚动时调用
47 | *
48 | * @param parent 父布局CoordinatorLayout
49 | * @param child 使用此Behavior的AppBarLayout
50 | * @param directTargetChild CoordinatorLayout的子View,或者是包含嵌套滚动操作的目标View
51 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
52 | * @param nestedScrollAxes 嵌套滚动的方向
53 | * @return 返回true表示接受滚动
54 | */
55 | @Override
56 | public boolean onStartNestedScroll(CoordinatorLayout parent, AppBarLayout child, View directTargetChild, View target, int nestedScrollAxes, int type) {
57 | return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0;
58 | }
59 |
60 |
61 | /**
62 | * 当嵌套滚动已由CoordinatorLayout接受时调用
63 | *
64 | * @param coordinatorLayout 父布局CoordinatorLayout
65 | * @param child 使用此Behavior的AppBarLayout
66 | * @param directTargetChild CoordinatorLayout的子View,或者是包含嵌套滚动操作的目标View
67 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
68 | */
69 | @Override
70 | public void onNestedScrollAccepted(@NonNull CoordinatorLayout coordinatorLayout, @NonNull AppBarLayout child, @NonNull View directTargetChild, @NonNull View target, int axes, int type) {
71 | super.onNestedScrollAccepted(coordinatorLayout, child, directTargetChild, target, axes, type);
72 | }
73 |
74 | /**
75 | * 当准备开始嵌套滚动时调用
76 | *
77 | * @param coordinatorLayout 父布局CoordinatorLayout
78 | * @param child 使用此Behavior的AppBarLayout
79 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
80 | * @param dx 用户在水平方向上滑动的像素数
81 | * @param dy 用户在垂直方向上滑动的像素数
82 | * @param consumed 输出参数,consumed[0]为水平方向应该消耗的距离,consumed[1]为垂直方向应该消耗的距离
83 | */
84 | @Override
85 | public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dx, int dy, int[] consumed, int type) {
86 | if (minY == 0) {
87 | minY = target.getHeight() + child.getHeight() - coordinatorLayout.getHeight();
88 | }
89 | /**
90 | * 如果nestedScrollview 布局内容少没有内部滑动,这时需要我们进行处理
91 | * 当nestedScrollview 内容很多时,我们不需要任何事情
92 | * */
93 | if (target.getScrollY() <= 0) {
94 | ay += dy;
95 | if (dy > 0 && ay >= minY) {
96 | dy = minY + dy - ay;//这里之所以没有让dy = 0;因为当快速滑动时就会有问题,快速滑动时dy的变化很大,自行琢磨一下,还不懂加群交流
97 | ay = minY;
98 | }
99 | if (dy < 0 && ay <= 0) {
100 | ay = 0;
101 | dy = 0;
102 | }
103 | }
104 | super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
105 | }
106 |
107 | /**
108 | * 嵌套滚动时调用
109 | *
110 | * @param coordinatorLayout 父布局CoordinatorLayout
111 | * @param child 使用此Behavior的AppBarLayout
112 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
113 | * @param dxConsumed 由目标View滚动操作消耗的水平像素数
114 | * @param dyConsumed 由目标View滚动操作消耗的垂直像素数
115 | * @param dxUnconsumed 由用户请求但是目标View滚动操作未消耗的水平像素数
116 | * @param dyUnconsumed 由用户请求但是目标View滚动操作未消耗的垂直像素数
117 | */
118 | @Override
119 | public void onNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) {
120 | super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
121 | }
122 |
123 | /**
124 | * 当嵌套滚动的子View准备快速滚动时调用
125 | *
126 | * @param coordinatorLayout 父布局CoordinatorLayout
127 | * @param child 使用此Behavior的AppBarLayout
128 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
129 | * @param velocityX 水平方向的速度
130 | * @param velocityY 垂直方向的速度
131 | * @return 如果Behavior消耗了快速滚动返回true
132 | */
133 | @Override
134 | public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, float velocityX, float velocityY) {
135 |
136 | return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
137 | }
138 |
139 | /**
140 | * 当嵌套滚动的子View快速滚动时调用
141 | *
142 | * @param coordinatorLayout 父布局CoordinatorLayout
143 | * @param child 使用此Behavior的AppBarLayout
144 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
145 | * @param velocityX 水平方向的速度
146 | * @param velocityY 垂直方向的速度
147 | * @param consumed 如果嵌套的子View消耗了快速滚动则为true
148 | * @return 如果Behavior消耗了快速滚动返回true
149 | */
150 | @Override
151 | public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, float velocityX, float velocityY, boolean consumed) {
152 | return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
153 | }
154 |
155 | /**
156 | * 当触摸时调用
157 | *
158 | * @param parent 父布局CoordinatorLayout
159 | * @param child 使用此Behavior的AppBarLayout
160 | * @param ev 手势事件
161 | */
162 | @Override
163 | public boolean onTouchEvent(CoordinatorLayout parent, AppBarLayout child, MotionEvent ev) {
164 | return super.onTouchEvent(parent, child, ev);
165 | }
166 |
167 | /**
168 | * 当触摸想要拦截时调用 关键所在 true 不拦截 false 拦截AppBarLayout的手势触摸
169 | *
170 | * @param parent 父布局CoordinatorLayout
171 | * @param child 使用此Behavior的AppBarLayout
172 | * @param ev 手势事件
173 | */
174 | @Override
175 | public boolean onInterceptTouchEvent(CoordinatorLayout parent, AppBarLayout child, MotionEvent ev) {
176 | return false;
177 | }
178 |
179 | /**
180 | * 嵌套滚动结束时被调用
181 | *
182 | * @param coordinatorLayout 父布局CoordinatorLayout
183 | * @param abl 使用此Behavior的AppBarLayout
184 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
185 | */
186 | @Override
187 | public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout abl, View target, int type) {
188 | super.onStopNestedScroll(coordinatorLayout, abl, target, type);
189 | }
190 |
191 | }
192 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JR-CoordinatorLayout
2 | CoordinatorLayout + AppBarLayout + NestedScrollView 组合使用实现地图背景,滑动悬停华丽效果。仿饿了么地图界面。TextView 实现FloatingActionButton效果
3 |
4 | [](https://www.apache.org/licenses/LICENSE-2.0)
5 | [](https://android-arsenal.com/details/1/6001)
6 | [](https://bintray.com/scwang90/maven/SmartRefreshLayout/_latestVersion)
7 | [](https://android-arsenal.com/api?level=12)
8 | [](http://www.methodscount.com/?lib=com.scwang.smartrefresh%3ASmartRefreshLayout%3A1.0.4)
9 |
10 |
11 |
12 |
13 | CoordinatorLayout就是加强版FrameLayout,适合作为应用顶层的布局(必须是根部局),提供交互行为
14 | 通过给子View设定Behavior可以实现他们的交互性为。Behavior能实现一系列的交互行为和布局变化,包括侧滑菜单、可滑动删除的UI元素、View之间跟随移动。
15 | 常用支持滑动效果的子View有:比如RecyclerView,NestedScrollView、TabLayout等 切记ScrollView是无效的!
16 |
17 | AppBarLayout是一个vertical的LinearLayout,其子View应通过setScrollFlags(int)或者xmL中的app:layout_scrollFlags来提供他们的Behavior。
18 | 具体的app:layout_scrollFlags有这么几个: scroll, exitUntilCollapsed, enterAlways, enterAlwaysCollapsed, snap
19 | 他必须严格地是CoordinatorLayout的子View,不然他一点作用都发挥不出来。
20 | AppBarLayout下方的滑动控件,比如RecyclerView,NestedScrollView(与AppBarLayout同属于CoordinatorLayout的子View,并列的关系,),必须严格地通过在xml中指出其滑动Behavior来与AppBarLayout进行绑定。
21 | 通常这样:app:layout_behavior="@string/appbar_scrolling_view_behavior"
22 |
23 | ## 特点功能:
24 |
25 | - 支持多点触摸
26 | - 支持嵌套多层的视图结构 Layout (ConstraintLayout,TabLayout...)
27 | - 支持和 NestedScrollView 的无缝同步滚动.
28 | - 支持回弹动画的插值器,实现各种炫酷的动画效果.
29 | - 支持设置主题来适配任何场景的 App,不会出现炫酷但很尴尬的情况.
30 |
31 | ## 完整效果图
32 | |||
33 |
34 | ## Demo
35 | [下载 APK-Demo](https://github.com/JR-Stone/img/blob/master/apk/app-coor.apk)
36 |
37 |
38 | ## 简单使用
39 | 人生的第一次写文章呀!还不知道我这第一次会被谁给夺走...还请多多指教,手下留情,少喷少喷!废话不多说,咱们言归正传,其实这三个控件组合可以制作出很多炫酷的界面,不过今天主要分享一下以地图为背景手动滑动透明AppBar渐变的效果,和之前的老版(饿了么)APP运输中订单详情界面一样;我们主要分享一下技术的难点,关于界面的布局及细节上的美化就留给各位开发者自己布局。先上代码和基本效果图
40 |
41 | #### 1. layout布局activity_main.xml
42 | ``` xml
43 |
44 |
50 |
51 |
55 |
56 |
61 |
62 |
69 |
70 |
75 |
76 |
77 |
78 |
79 |
87 |
88 |
93 |
94 |
102 |
103 |
104 |
105 |
106 |
112 |
113 | ```
114 | #### 2. java代码 MianActivity.java
115 | ```java
116 | public class MainActivity extends AppCompatActivity {
117 | @BindView(R.id.appBar)
118 | AppBarLayout appBarLayout;
119 | @BindView(R.id.nestScrollView)
120 | NestedScrollView scrollView;
121 | @BindView(R.id.mapView)
122 | MapView mapView;
123 |
124 | private CoordinatorLayout.LayoutParams layoutParams;
125 | private AMap aMap;
126 |
127 | @Override
128 | protected void onCreate(Bundle savedInstanceState) {
129 | super.onCreate(savedInstanceState);
130 | setContentView(R.layout.activity_main);
131 | ButterKnife.bind(this);
132 | mapView.onCreate(savedInstanceState);
133 | if (aMap == null) {
134 | aMap = mapView.getMap();
135 | }
136 | layoutParams = (CoordinatorLayout.LayoutParams) scrollView.getLayoutParams();
137 | layoutParams.setMargins(30, 0, 30, 0);
138 | scrollView.setLayoutParams(layoutParams);
139 | appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
140 | @Override
141 | public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
142 | float a = (float) 30 / appBarLayout.getTotalScrollRange();
143 | int side = (int) Math.rint(a * i + 30);
144 | layoutParams.setMargins(side, 0, side, 0);
145 | scrollView.setLayoutParams(layoutParams);
146 | if (Math.abs(i) > 0) {
147 | float alpha = (float) Math.abs(i) / appBarLayout.getTotalScrollRange();
148 | appBarLayout.setAlpha(alpha);
149 | scrollView.getBackground().mutate().setAlpha(Math.round(alpha * 255));
150 | } else {
151 | appBarLayout.setAlpha(0);
152 | scrollView.getBackground().mutate().setAlpha(0);
153 | }
154 | }
155 | });
156 | }
157 | }
158 | ```
159 | #### 3. 导入包
160 | ```
161 | /*高德地图*/
162 | implementation 'com.amap.api:3dmap:latest.integration'
163 | /*注释*/
164 | implementation 'com.jakewharton:butterknife:8.7.0'
165 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
166 | ```
167 | |默认|滑动中|置顶|
168 | |:---:|:---:|:---:|
169 | ||||
170 |
171 | #### 4. 到此基本的效果已经出来了,如果把地图换成一站图片或者简单的布局那么现在已经可以支持了。但是如果是地图的话,那就有问题了;你会发现AppBarLayout透明部分触摸屏幕滑动地图会很困难,基本上一滑动下面的NestedScrollView就会跟着滑动而地图就不能操作了。看下图...
172 | 
173 |
174 | #### 那这个问题怎么解决呢?其实很简单,那就是重写AppBarLayout.Behavior,大家有时间也可以去研究研究behavior,CoordinatorLayout的很多酷炫的效果都是通过behavior来实现的。同样这里也是要重写AppBarLayout.Behavior中的onInterceptTouchEvent()方法,他的作用就是拦截触摸,其中有个boolean类型的返回值,true 表示不拦截,false表示拦截。默认为true,我们只需要返回false就OK了,就是这么简单。上代码(为了让大家更清楚的了解AppBarLayout.Behavior,我将其他主要方法也列了出来并备注了作用)
175 | ```java
176 | /**
177 | * @author jr
178 | */
179 | public class AppBarBehavior extends AppBarLayout.Behavior{
180 | public AppBarBehavior() {
181 | }
182 |
183 | public AppBarBehavior(Context context, AttributeSet attrs) {
184 | super(context, attrs);
185 | }
186 |
187 | /**
188 | * AppBarLayout布局时调用
189 | *
190 | * @param parent 父布局CoordinatorLayout
191 | * @param abl 使用此Behavior的AppBarLayout
192 | * @param layoutDirection 布局方向
193 | * @return 返回true表示子View重新布局,返回false表示请求默认布局
194 | */
195 | @Override
196 | public boolean onLayoutChild(CoordinatorLayout parent, AppBarLayout abl, int layoutDirection) {
197 | return super.onLayoutChild(parent, abl, layoutDirection);
198 | }
199 |
200 | /**
201 | * 当CoordinatorLayout的子View尝试发起嵌套滚动时调用
202 | *
203 | * @param parent 父布局CoordinatorLayout
204 | * @param child 使用此Behavior的AppBarLayout
205 | * @param directTargetChild CoordinatorLayout的子View,或者是包含嵌套滚动操作的目标View
206 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
207 | * @param nestedScrollAxes 嵌套滚动的方向
208 | * @return 返回true表示接受滚动
209 | */
210 | @Override
211 | public boolean onStartNestedScroll(CoordinatorLayout parent, AppBarLayout child, View directTargetChild, View target, int nestedScrollAxes, int type) {
212 | return super.onStartNestedScroll(parent, child, directTargetChild, target, nestedScrollAxes, type);
213 | }
214 |
215 | /**
216 | * 当嵌套滚动已由CoordinatorLayout接受时调用
217 | *
218 | * @param coordinatorLayout 父布局CoordinatorLayout
219 | * @param child 使用此Behavior的AppBarLayout
220 | * @param directTargetChild CoordinatorLayout的子View,或者是包含嵌套滚动操作的目标View
221 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
222 | */
223 | @Override
224 | public void onNestedScrollAccepted(@NonNull CoordinatorLayout coordinatorLayout, @NonNull AppBarLayout child, @NonNull View directTargetChild, @NonNull View target, int axes, int type) {
225 | super.onNestedScrollAccepted(coordinatorLayout, child, directTargetChild, target, axes, type);
226 | }
227 |
228 | /**
229 | * 当准备开始嵌套滚动时调用
230 | *
231 | * @param coordinatorLayout 父布局CoordinatorLayout
232 | * @param child 使用此Behavior的AppBarLayout
233 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
234 | * @param dx 用户在水平方向上滑动的像素数
235 | * @param dy 用户在垂直方向上滑动的像素数
236 | * @param consumed 输出参数,consumed[0]为水平方向应该消耗的距离,consumed[1]为垂直方向应该消耗的距离
237 | */
238 | @Override
239 | public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dx, int dy, int[] consumed, int type) {
240 | super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
241 | }
242 |
243 | /**
244 | * 嵌套滚动时调用
245 | *
246 | * @param coordinatorLayout 父布局CoordinatorLayout
247 | * @param child 使用此Behavior的AppBarLayout
248 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
249 | * @param dxConsumed 由目标View滚动操作消耗的水平像素数
250 | * @param dyConsumed 由目标View滚动操作消耗的垂直像素数
251 | * @param dxUnconsumed 由用户请求但是目标View滚动操作未消耗的水平像素数
252 | * @param dyUnconsumed 由用户请求但是目标View滚动操作未消耗的垂直像素数
253 | */
254 | @Override
255 | public void onNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) {
256 | super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
257 | }
258 |
259 | /**
260 | * 当嵌套滚动的子View准备快速滚动时调用
261 | *
262 | * @param coordinatorLayout 父布局CoordinatorLayout
263 | * @param child 使用此Behavior的AppBarLayout
264 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
265 | * @param velocityX 水平方向的速度
266 | * @param velocityY 垂直方向的速度
267 | * @return 如果Behavior消耗了快速滚动返回true
268 | */
269 | @Override
270 | public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, float velocityX, float velocityY) {
271 | return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
272 | }
273 |
274 | /**
275 | * 当嵌套滚动的子View快速滚动时调用
276 | *
277 | * @param coordinatorLayout 父布局CoordinatorLayout
278 | * @param child 使用此Behavior的AppBarLayout
279 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
280 | * @param velocityX 水平方向的速度
281 | * @param velocityY 垂直方向的速度
282 | * @param consumed 如果嵌套的子View消耗了快速滚动则为true
283 | * @return 如果Behavior消耗了快速滚动返回true
284 | */
285 | @Override
286 | public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, float velocityX, float velocityY, boolean consumed) {
287 | return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
288 | }
289 |
290 | /**
291 | * 当触摸时调用
292 | *
293 | * @param parent 父布局CoordinatorLayout
294 | * @param child 使用此Behavior的AppBarLayout
295 | * @param ev 手势事件
296 | */
297 | @Override
298 | public boolean onTouchEvent(CoordinatorLayout parent, AppBarLayout child, MotionEvent ev) {
299 | return super.onTouchEvent(parent, child, ev);
300 | }
301 |
302 | /**
303 | * 当触摸想要拦截时调用 关键所在 true 不拦截 false 拦截AppBarLayout的手势触摸
304 | *
305 | * @param parent 父布局CoordinatorLayout
306 | * @param child 使用此Behavior的AppBarLayout
307 | * @param ev 手势事件
308 | */
309 | @Override
310 | public boolean onInterceptTouchEvent(CoordinatorLayout parent, AppBarLayout child, MotionEvent ev) {
311 | return false;
312 | }
313 |
314 | /**
315 | * 当定制滚动时调用
316 | *
317 | * @param coordinatorLayout 父布局CoordinatorLayout
318 | * @param abl 使用此Behavior的AppBarLayout
319 | * @param target 发起嵌套滚动的目标View(即AppBarLayout下面的ScrollView或RecyclerView)
320 | */
321 | @Override
322 | public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout abl, View target, int type) {
323 | super.onStopNestedScroll(coordinatorLayout, abl, target, type);
324 | }
325 | }
326 | ```
327 |
328 | #### 4. 重写好AppBarLayout.Behavior类之后,在我们的项目中引用一下就好了;引用方法也很简单,在Strings.xml中添加
329 | ```xml com.stone.view.AppBarBehavior ```
330 | #### 然后在布局中的AppBarLayout上进行引用
331 | ```xml
332 |
338 |
339 |
343 |
344 |
350 | ...
351 | ```
352 |
353 | #### 5. OK,引用好之后你会发现地图已经可以随意拖动了,到这里又有小伙伴发现怎么自己的FloatingActionButton(中间的圆圈)不能写文字呢?其实作者并不是直接用的android.support.design.widget.FloatingActionButton,而是利用TextView的style属性,看代码
354 | ```xml
355 |
367 | ```
368 | #### 用这个TextView替代布局中的android.support.design.widget.FloatingActionButton大事搞定。关于界面的美化各位自行发挥,完整代码直接下载就可运行。
369 |
370 | ## 赞赏
371 |
372 | 如果你喜欢我的分享,感觉这篇文章帮助到了你,可以点右上角 "Star" 支持一下 谢谢! ^_^
373 | 你也还可以扫描下面的二维码~ 请作者喝一杯咖啡。
374 |
375 |  
376 |
377 | > 如果希望捐赠之后能获得相关的帮助,可以选择加入下面的交流群,在群里可以直接和作者进行交流,与问题反馈。
378 | 如果在捐赠留言中备注名称,将会被记录到列表中~ 如果你也是github开源作者,捐赠时可以留下github项目地址或者个人主页地址,链接将会被添加到列表中起到互相推广的作用
379 | [捐赠列表](https://github.com/JR-Stone/img/blob/master/payList.md)
380 |
381 | 
382 | #### 进群须知
383 | 加入此群,大家可以相互讨论本库的相关使用和出现的问题,群主会很认真很努力的解决问题,但也不能保证能完美解决。
384 |
385 | #### 友情链接
386 | [github/faith-hb/WidgetCase](https://github.com/faith-hb/WidgetCase)
387 | [github/razerdp](https://github.com/razerdp)
388 | [github/SuperChenC/s-mvp](https://github.com/SuperChenC/s-mvp)
389 | [github/KingJA/LoadSir](https://github.com/KingJA/LoadSir)
390 | [github/jianshijiuyou](https://github.com/jianshijiuyou)
391 | [github/sugarya](https://github.com/sugarya)
392 | [github/stormzhang](https://github.com/stormzhang)
393 |
--------------------------------------------------------------------------------