├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── 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-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── .gitignore │ │ │ └── layout │ │ │ │ ├── activity_main.xml │ │ │ │ └── item_layout.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── qingmei2 │ │ │ └── slidebottomlayout_android │ │ │ ├── MainActivity.java │ │ │ └── MainActivityListAdapter.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── qingmei2 │ │ │ └── slidebottomlayout_android │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── qingmei2 │ │ └── slidebottomlayout_android │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── library ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ ├── strings.xml │ │ │ │ └── attrs.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── qingmei2 │ │ │ │ └── library │ │ │ │ ├── ShortSlideListener.java │ │ │ │ └── SlideBottomLayout.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── qingmei2 │ │ │ └── library │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── qingmei2 │ │ └── library │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── pictures └── usage.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── LICENSE ├── gradle.properties ├── gradlew.bat ├── README.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | -------------------------------------------------------------------------------- /pictures/usage.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingmei2/SlideBottomLayout-Android/HEAD/pictures/usage.gif -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | library 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SlideBottomLayout-Android 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingmei2/SlideBottomLayout-Android/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingmei2/SlideBottomLayout-Android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingmei2/SlideBottomLayout-Android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingmei2/SlideBottomLayout-Android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingmei2/SlideBottomLayout-Android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingmei2/SlideBottomLayout-Android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingmei2/SlideBottomLayout-Android/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/qingmei2/SlideBottomLayout-Android/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/qingmei2/SlideBottomLayout-Android/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/qingmei2/SlideBottomLayout-Android/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/qingmei2/SlideBottomLayout-Android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea 3 | .gradle 4 | /local.properties 5 | /.idea/workspace.xml 6 | /.idea/libraries 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /library/src/main/java/com/qingmei2/library/ShortSlideListener.java: -------------------------------------------------------------------------------- 1 | package com.qingmei2.library; 2 | 3 | /** 4 | * Created by QingMei on 2017/8/28. 5 | * desc: 6 | */ 7 | 8 | public interface ShortSlideListener { 9 | 10 | void onShortSlide(float eventY); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Sep 01 18:34:07 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-4.1-all.zip 7 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /library/src/test/java/com/qingmei2/library/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.qingmei2.library; 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 | } -------------------------------------------------------------------------------- /app/src/test/java/com/qingmei2/slidebottomlayout_android/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.qingmei2.slidebottomlayout_android; 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 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The QrCodeScannerView-Android License 3 | 4 | Copyright (c) 2017 qingmei2 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/qingmei2/library/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.qingmei2.library; 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 | * Instrumentation 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() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.qingmei2.library.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/qingmei2/slidebottomlayout_android/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.qingmei2.slidebottomlayout_android; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | 8 | public class MainActivity extends AppCompatActivity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_main); 14 | 15 | initRecyclerView(); 16 | } 17 | 18 | private void initRecyclerView() { 19 | RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); 20 | MainActivityListAdapter adapter = new MainActivityListAdapter(); 21 | recyclerView.setAdapter(adapter); 22 | recyclerView.setLayoutManager(new LinearLayoutManager(this)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/qingmei2/slidebottomlayout_android/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.qingmei2.slidebottomlayout_android; 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 | * Instrumentation 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() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.qingmei2.slidebottomlayout_android", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 /Users/fcn-mq/Library/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 | -------------------------------------------------------------------------------- /library/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 /Users/fcn-mq/Library/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/res/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Android template 3 | # Built application files 4 | *.apk 5 | *.ap_ 6 | 7 | # Files for the ART/Dalvik VM 8 | *.dex 9 | 10 | # Java class files 11 | *.class 12 | 13 | # Generated files 14 | bin/ 15 | gen/ 16 | out/ 17 | 18 | # Gradle files 19 | .gradle/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | 28 | # Log Files 29 | *.log 30 | 31 | # Android Studio Navigation editor temp files 32 | .navigation/ 33 | 34 | # Android Studio captures folder 35 | captures/ 36 | 37 | # Intellij 38 | *.iml 39 | .idea/workspace.xml 40 | .idea/tasks.xml 41 | .idea/gradle.xml 42 | .idea/dictionaries 43 | .idea/libraries 44 | 45 | # Keystore files 46 | *.jks 47 | 48 | # External native build folder generated in Android Studio 2.2 and later 49 | .externalNativeBuild 50 | 51 | # Google Services (e.g. APIs or Firebase) 52 | google-services.json 53 | 54 | # Freeline 55 | freeline.py 56 | freeline/ 57 | freeline_project_description.json 58 | 59 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.3" 6 | defaultConfig { 7 | applicationId "com.qingmei2.slidebottomlayout_android" 8 | minSdkVersion 16 9 | targetSdkVersion 26 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 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:26.1.0' 28 | compile 'com.android.support:recyclerview-v7:26.1.0' 29 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 30 | testCompile 'junit:junit:4.12' 31 | compile project(':library') 32 | } 33 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 16 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | 23 | task sourcesJar(type: Jar) { 24 | from android.sourceSets.main.java.srcDirs 25 | classifier = 'sources' 26 | } 27 | 28 | task javadoc(type: Javadoc) { 29 | failOnError false 30 | source = android.sourceSets.main.java.sourceFiles 31 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 32 | } 33 | 34 | task javadocJar(type: Jar, dependsOn: javadoc) { 35 | classifier = 'javadoc' 36 | from javadoc.destinationDir 37 | } 38 | 39 | artifacts { 40 | archives sourcesJar 41 | archives javadocJar 42 | } 43 | } 44 | 45 | dependencies { 46 | compile fileTree(dir: 'libs', include: ['*.jar']) 47 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 48 | exclude group: 'com.android.support', module: 'support-annotations' 49 | }) 50 | compile 'com.android.support:appcompat-v7:26.+' 51 | testCompile 'junit:junit:4.12' 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/qingmei2/slidebottomlayout_android/MainActivityListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.qingmei2.slidebottomlayout_android; 2 | 3 | import android.support.constraint.ConstraintLayout; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.Toast; 9 | 10 | /** 11 | * Created by QingMei on 2017/8/29. 12 | * desc: 13 | */ 14 | 15 | public class MainActivityListAdapter extends RecyclerView.Adapter { 16 | 17 | public MainActivityListAdapter() { 18 | } 19 | 20 | @Override 21 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 22 | View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_layout, parent, false); 23 | return new ViewHolder(inflate); 24 | } 25 | 26 | @Override 27 | public void onBindViewHolder(final ViewHolder holder, final int position) { 28 | holder.background.setOnClickListener(new View.OnClickListener() { 29 | @Override 30 | public void onClick(View view) { 31 | Toast.makeText(holder.background.getContext(), "click:" + position, Toast.LENGTH_SHORT).show(); 32 | } 33 | }); 34 | } 35 | 36 | @Override 37 | public int getItemCount() { 38 | return 20; 39 | } 40 | 41 | static class ViewHolder extends RecyclerView.ViewHolder { 42 | 43 | private final ConstraintLayout background; 44 | 45 | public ViewHolder(View itemView) { 46 | super(itemView); 47 | background = (ConstraintLayout) itemView.findViewById(R.id.item_top); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | 21 | 22 | 31 | 32 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 21 | 22 | 29 | 30 | 36 | 37 | 38 | 48 | 49 | 56 | 57 | 58 | 59 | 66 | 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## SlideBottomLayout-Android 2 | 3 | [![](https://jitpack.io/v/qingmei2/SlideBottomLayout-Android.svg)](https://jitpack.io/#qingmei2/SlideBottomLayout-Android) 4 | 5 | ## Android底部上拉控件 6 | 7 | ![usage](https://github.com/qingmei2/SlideBottomLayout-Android/blob/master/pictures/usage.gif) 8 | 9 | ### If you have a problem (using a problem, or encounter a bug), welcome to provide your issues! Thank you for using SlideBottomLayout-Android! 10 | 11 | ##

Usage

12 | ### 1. Add code into your Project Build.gradle: 13 | ``` 14 | allprojects { 15 | repositories { 16 | ... 17 | maven { url 'https://jitpack.io' } 18 | } 19 | } 20 | ``` 21 | ### 2.Add code into your Module Build.gradle: 22 | ``` 23 | dependencies { 24 | compile 'com.github.qingmei2:SlideBottomLayout-Android:1.2.3' 25 | } 26 | ``` 27 | ### 3.Add view in your layout: 28 | 29 | > Warning:this Layout just can hold one child-View like the ScrollView, so you need create a viewGroup to organize other views 30 | 31 | ```xml 32 |     39 | 40 | 41 | 42 | 46 | 47 | 56 | 57 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | ``` 68 | 69 | ## API(Please reading the Sample code) 70 | 71 | | Method                                                                    |detail                  |return | 72 | | ------------- | ------------- | -----| 73 | | show()   | show this view | Void | 74 | | hide()             | hide this view    | Void | 75 | | arriveTop()| whether the view is arrive the top | Boolean | 76 | | switchVisible() |switch this view's state (show or hide) | Void| 77 | | setVisibilityHeight(float visibilityHeight) |the controlSlideBottomLayout automatically switches the threshold of the state | Void| 78 | | setHideWeight(float hideWeight) |the childView Initially visible height | Void| 79 | 80 | Lisence 81 | ------- 82 | The SlideBottomLayout-Android License 83 | 84 | Copyright (c) 2017 qingmei2 85 | 86 | Licensed under the Apache License, Version 2.0 (the "License"); 87 | you may not use this file except in compliance with the License. 88 | You may obtain a copy of the License at 89 | 90 | http://www.apache.org/licenses/LICENSE-2.0 91 | 92 | Unless required by applicable law or agreed to in writing, software 93 | distributed under the License is distributed on an "AS IS" BASIS, 94 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 95 | See the License for the specific language governing permissions and 96 | limitations under the License. 97 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /library/src/main/java/com/qingmei2/library/SlideBottomLayout.java: -------------------------------------------------------------------------------- 1 | package com.qingmei2.library; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Color; 6 | import android.support.annotation.NonNull; 7 | import android.support.annotation.Nullable; 8 | import android.util.AttributeSet; 9 | import android.view.MotionEvent; 10 | import android.view.View; 11 | import android.widget.LinearLayout; 12 | import android.widget.Scroller; 13 | 14 | 15 | /** 16 | * Created by QingMei on 2017/8/25. 17 | * desc: 18 | */ 19 | public class SlideBottomLayout extends LinearLayout { 20 | 21 | public void setShortSlideListener(ShortSlideListener listener) { 22 | this.shortSlideListener = listener; 23 | } 24 | 25 | private ShortSlideListener shortSlideListener; 26 | 27 | /** 28 | * The {@link MotionEvent#ACTION_DOWN} gesture location. 29 | */ 30 | private int downY; 31 | 32 | /** 33 | * The {@link MotionEvent#ACTION_MOVE} gesture location. 34 | */ 35 | private int moveY; 36 | 37 | /** 38 | * the value of moved distance by the gesture. When the value was modified and not exceed 39 | * the {@link #movedMaxDis}, then make this ViewGroup move. 40 | */ 41 | private int movedDis; 42 | 43 | /** 44 | * The max distance that the {@link SlideBottomLayout} can scroll to, it used to compare with the 45 | * {@link #downY}, determine whether it can slide by the gesture. 46 | */ 47 | private int movedMaxDis; 48 | 49 | /** 50 | * ChildView of the {@link SlideBottomLayout}, you can set a Layout such as the {@link LinearLayout}、 51 | * {@link android.widget.RelativeLayout} ect. 52 | * We set the rules that {@link SlideBottomLayout} just can have one child-view, or else get a 53 | * {@link RuntimeException} at {@link #onFinishInflate()} 54 | */ 55 | private View childView; 56 | 57 | /** 58 | * The control {@link SlideBottomLayout} automatically switches the threshold of the state. if 59 | * this ViewGroup moved distance more than {@link #movedMaxDis} * it, switch the state of 60 | * {@link #arriveTop} right now. 61 | *

62 | * See the {@link #touchActionUp(float)}. 63 | */ 64 | private float hideWeight = 0.25f; 65 | 66 | public void setHideWeight(float hideWeight) { 67 | if (hideWeight <= 0 || hideWeight > 1) 68 | throw new IllegalArgumentException("hideWeight should belong (0f,1f]"); 69 | this.hideWeight = hideWeight; 70 | } 71 | 72 | private Scroller mScroller; 73 | 74 | /** 75 | * It means the {@link #childView} is arriving the top of parent or else. 76 | */ 77 | private boolean arriveTop = false; 78 | 79 | /** 80 | * the {@link #childView} Initially visible height 81 | */ 82 | private float visibilityHeight; 83 | 84 | public void setVisibilityHeight(float visibilityHeight) { 85 | this.visibilityHeight = visibilityHeight; 86 | } 87 | 88 | public SlideBottomLayout(@NonNull Context context) { 89 | super(context); 90 | } 91 | 92 | public SlideBottomLayout(@NonNull Context context, @Nullable AttributeSet attrs) { 93 | super(context, attrs); 94 | initAttrs(context, attrs); 95 | } 96 | 97 | public SlideBottomLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 98 | super(context, attrs, defStyleAttr); 99 | initAttrs(context, attrs); 100 | } 101 | 102 | /** 103 | * Get the config from {@link R.styleable}, then init other configrations{@link #initConfig(Context)}. 104 | * 105 | * @param context the {@link Context} 106 | * @param attrs the configs in layout attrs. 107 | */ 108 | private void initAttrs(Context context, AttributeSet attrs) { 109 | final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlideBottomLayout); 110 | visibilityHeight = ta.getDimension(R.styleable.SlideBottomLayout_handler_height, 0); 111 | ta.recycle(); 112 | 113 | initConfig(context); 114 | } 115 | 116 | private void initConfig(Context context) { 117 | if (mScroller == null) 118 | mScroller = new Scroller(context); 119 | this.setBackgroundColor(Color.TRANSPARENT); 120 | } 121 | 122 | /** 123 | * It start a judgement for ensure the child-view be unique in this method,then assgin it 124 | * to {{@link #childView}. 125 | * this method will be called before the {@link #onMeasure(int, int)} 126 | */ 127 | @Override 128 | protected void onFinishInflate() { 129 | super.onFinishInflate(); 130 | if (getChildCount() == 0 || getChildAt(0) == null) { 131 | throw new RuntimeException("there have no child-View in the SlideBottomLayout!"); 132 | } 133 | if (getChildCount() > 1) { 134 | throw new RuntimeException("there just alow one child-View in the SlideBottomLayout!"); 135 | } 136 | childView = getChildAt(0); 137 | } 138 | 139 | @Override 140 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 141 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 142 | movedMaxDis = (int) (childView.getMeasuredHeight() - visibilityHeight); 143 | } 144 | 145 | @Override 146 | protected void onLayout(boolean changed, int l, int t, int r, int b) { 147 | super.onLayout(changed, l, t, r, b); 148 | childView.layout(0, movedMaxDis, childView.getMeasuredWidth(), childView.getMeasuredHeight() + movedMaxDis); 149 | } 150 | 151 | @Override 152 | public boolean onTouchEvent(MotionEvent event) { 153 | final float dy = event.getY(); 154 | switch (event.getAction()) { 155 | case MotionEvent.ACTION_DOWN: 156 | if (touchActionDown(dy)) 157 | return true; 158 | break; 159 | case MotionEvent.ACTION_MOVE: 160 | if (touchActionMove(dy)) 161 | return true; 162 | break; 163 | case MotionEvent.ACTION_UP: 164 | if (touchActionUp(dy)) 165 | return true; 166 | break; 167 | } 168 | return super.onTouchEvent(event); 169 | } 170 | 171 | @Override 172 | public void computeScroll() { 173 | super.computeScroll(); 174 | if (mScroller == null) 175 | mScroller = new Scroller(getContext()); 176 | if (mScroller.computeScrollOffset()) { 177 | scrollTo(0, mScroller.getCurrY()); 178 | postInvalidate(); 179 | } 180 | } 181 | 182 | /** 183 | * When the touch event is {@link MotionEvent#ACTION_UP}, 184 | * then judge the state of view group and control the {@link Scroller} to scroll. 185 | *

186 | * In this ViewGroup, we set the rules that is if this scroll gesture's move distance 187 | * more than {@link #movedMaxDis} * {@link #hideWeight}(default hideWeight value is 1/4 heights 188 | * of this ViewGroup), then call {@link #hide()} or {@link #show()} right now. which method will 189 | * be call depends on {@link #arriveTop}. 190 | *

movedMaxDis * hideWeight) { 200 | switchVisible(); 201 | } else { 202 | if (shortSlideListener != null) { 203 | shortSlideListener.onShortSlide(eventY); 204 | } else { 205 | hide(); 206 | } 207 | } 208 | return true; 209 | } 210 | 211 | /** 212 | * When the touch event is {@link MotionEvent#ACTION_MOVE}, 213 | * then judge the state of view group and control the {@link Scroller} to scroll. 214 | *

215 | * In this ViewGroup, we set the rules that is if this scroll gesture's move distance 216 | * more than {@link #movedMaxDis} * {@link #hideWeight}(default hideWeight value is 1/4 heights of this ViewGroup), 217 | * then call {@link #hide()} or {@link #show()} right now. 218 | *

219 | * 220 | * @param eventY The location of trigger 221 | * @return Be used to determine consume this event or else. 222 | */ 223 | public boolean touchActionMove(float eventY) { 224 | moveY = (int) eventY; 225 | //the dy is sum of the move distance, the value > 0 means scroll up, the value < 0 means scroll down. 226 | final int dy = downY - moveY; 227 | if (dy > 0) { //scroll up 228 | movedDis += dy; 229 | if (movedDis > movedMaxDis) 230 | movedDis = movedMaxDis; 231 | 232 | if (movedDis < movedMaxDis) { 233 | scrollBy(0, dy); 234 | downY = moveY; 235 | return true; 236 | } 237 | } else { //scroll down 238 | movedDis += dy; 239 | if (movedDis < 0) movedDis = 0; 240 | if (movedDis > 0) { 241 | scrollBy(0, dy); 242 | } 243 | downY = moveY; 244 | return true; 245 | } 246 | return false; 247 | } 248 | 249 | /** 250 | * When the touch event is {@link MotionEvent#ACTION_DOWN}, 251 | * Record the location of this action. 252 | * 253 | * @param eventY The location of trigger 254 | * @return Be used to determine consume this event or else. 255 | */ 256 | public boolean touchActionDown(float eventY) { 257 | downY = (int) eventY; 258 | 259 | //Whether custom this gesture. 260 | if (!arriveTop && downY < movedMaxDis) { 261 | return false; 262 | } else 263 | return true; 264 | } 265 | 266 | /** 267 | * the extand method for showing {@link SlideBottomLayout} 268 | */ 269 | public void show() { 270 | scroll2TopImmediate(); 271 | } 272 | 273 | /** 274 | * the extand method for hiding {@link SlideBottomLayout} 275 | */ 276 | public void hide() { 277 | scroll2BottomImmediate(); 278 | } 279 | 280 | /** 281 | * @return The ViewGroup is arrive top or else. 282 | */ 283 | public boolean switchVisible() { 284 | if (arriveTop()) 285 | hide(); 286 | else 287 | show(); 288 | return arriveTop(); 289 | } 290 | 291 | public boolean arriveTop() { 292 | return this.arriveTop; 293 | } 294 | 295 | public void scroll2TopImmediate() { 296 | mScroller.startScroll(0, getScrollY(), 0, (movedMaxDis - getScrollY())); 297 | invalidate(); 298 | movedDis = movedMaxDis; 299 | arriveTop = true; 300 | } 301 | 302 | public void scroll2BottomImmediate() { 303 | mScroller.startScroll(0, getScrollY(), 0, -getScrollY()); 304 | postInvalidate(); 305 | movedDis = 0; 306 | arriveTop = false; 307 | } 308 | } 309 | 310 | --------------------------------------------------------------------------------