├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable │ │ │ │ └── h.png │ │ │ ├── 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 │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── mran │ │ │ └── animationbottombar │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── mran │ │ │ └── animationbottombar │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── mran │ │ └── animationbottombar │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── bottombar ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── attrs.xml │ │ │ └── drawable │ │ │ │ └── h.png │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── mran │ │ │ └── bottombar │ │ │ ├── BottomItem.java │ │ │ └── AnimationBottomBar.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── mran │ │ │ └── bottombar │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── mran │ │ └── bottombar │ │ └── ExampleInstrumentedTest.java ├── build.gradle └── proguard-rules.pro ├── settings.gradle ├── .idea ├── copyright │ └── profiles_settings.xml ├── markdown-navigator │ └── profiles_settings.xml ├── inspectionProfiles │ ├── profiles_settings.xml │ └── Project_Default.xml ├── modules.xml ├── runConfigurations.xml ├── compiler.xml ├── gradle.xml └── misc.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /bottombar/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':bottombar' 2 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mran/AnimationBottomBar/HEAD/app/src/main/res/drawable/h.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AnimationBottomBar 3 | 4 | -------------------------------------------------------------------------------- /bottombar/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BottomBar 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mran/AnimationBottomBar/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /bottombar/src/main/res/drawable/h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mran/AnimationBottomBar/HEAD/bottombar/src/main/res/drawable/h.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mran/AnimationBottomBar/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mran/AnimationBottomBar/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mran/AnimationBottomBar/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mran/AnimationBottomBar/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mran/AnimationBottomBar/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mran/AnimationBottomBar/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/Mran/AnimationBottomBar/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/Mran/AnimationBottomBar/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/Mran/AnimationBottomBar/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/Mran/AnimationBottomBar/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /bottombar/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ffe100 4 | #FF5C4E71 5 | #639fff 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Aug 20 09:52:16 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-5.0-milestone-1-all.zip 7 | -------------------------------------------------------------------------------- /bottombar/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /bottombar/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /bottombar/src/main/java/com/mran/bottombar/BottomItem.java: -------------------------------------------------------------------------------- 1 | package com.mran.bottombar; 2 | 3 | import android.support.annotation.DrawableRes; 4 | 5 | /** 6 | * Created by M on 2017/8/29. 7 | */ 8 | 9 | public class BottomItem { 10 | int drawableRes; 11 | String title; 12 | // private ImageView mImageView; 13 | public BottomItem(@DrawableRes int drawableRes,String title){ 14 | this.drawableRes=drawableRes; 15 | this.title=title; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /bottombar/src/test/java/com/mran/bottombar/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.mran.bottombar; 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/mran/animationbottombar/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.mran.animationbottombar; 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 | } -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /bottombar/src/androidTest/java/com/mran/bottombar/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.mran.bottombar; 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.mran.bottombar.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/mran/animationbottombar/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.mran.animationbottombar; 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.mran.animationbottombar", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /bottombar/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion "28.0.3" 6 | 7 | defaultConfig { 8 | minSdkVersion 21 9 | targetSdkVersion 28 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 | 24 | dependencies { 25 | implementation fileTree(dir: 'libs', include: ['*.jar']) 26 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { 27 | exclude group: 'com.android.support', module: 'support-annotations' 28 | }) 29 | implementation 'com.android.support:appcompat-v7:28.0.0' 30 | testImplementation 'junit:junit:4.12' 31 | } 32 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Sun Aug 20 09:53:23 CST 2017 16 | systemProp.https.proxyPort=8087 17 | systemProp.http.proxyHost=127.0.0.1 18 | org.gradle.jvmargs=-Xmx1536m 19 | systemProp.https.proxyHost=127.0.0.1 20 | systemProp.http.proxyPort=8087 21 | -------------------------------------------------------------------------------- /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 C:\Users\M\AppData\Local\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 | -------------------------------------------------------------------------------- /bottombar/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 C:\Users\M\AppData\Local\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/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion "28.0.3" 6 | defaultConfig { 7 | applicationId "com.mran.animationbottombar" 8 | minSdkVersion 21 9 | targetSdkVersion 28 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 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | implementation 'com.android.support:appcompat-v7:28.0.0' 28 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 29 | implementation project(':bottombar') 30 | testImplementation 'junit:junit:4.12' 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/mran/animationbottombar/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.mran.animationbottombar; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.util.Log; 6 | 7 | import com.mran.bottombar.AnimationBottomBar; 8 | import com.mran.bottombar.BottomItem; 9 | 10 | public class MainActivity extends AppCompatActivity { 11 | AnimationBottomBar mAnimationBottomBar; 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | mAnimationBottomBar = (AnimationBottomBar) findViewById(R.id.bottom); 18 | try { 19 | mAnimationBottomBar.addItem(new BottomItem(R.drawable.h, "zero")) 20 | .addItem(new BottomItem(R.drawable.h, "one")) 21 | .addItem(new BottomItem(R.drawable.h, "two")) 22 | .addItem(new BottomItem(R.drawable.h, "three")) 23 | .addItem(new BottomItem(R.drawable.h, "four")) 24 | .build(); 25 | } catch (Exception e) { 26 | e.printStackTrace(); 27 | } 28 | mAnimationBottomBar.setItemSelectListener(new AnimationBottomBar.OnItemSelectListener() { 29 | @Override 30 | public void onItemSelectListener(int position) { 31 | Log.d("MainActivity", "onItemSelectListener: position"+position); 32 | } 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AnimationBottomBar 2 | 3 | I saw a awesome bottomBar Design from [dribbble](https://dribbble.com/shots/2071319-GIF-of-the-Tapbar-Interactions),and I make it come true. 4 | just like this 5 | 6 | ![](http://oe38oe3ti.bkt.clouddn.com/17-9-6/16156701.jpg) 7 | 8 | but i make it a little different 9 | 10 | ![](http://oe38oe3ti.bkt.clouddn.com/17-9-8/88688725.jpg) 11 | 12 | and if you want to know how to make it ,you can see [this](https://mran.github.io/2017/09/08/%E5%81%9A%E4%B8%80%E4%B8%AAbottomBar/) 13 | 14 | you can push issue to make it better,i'm happy to help you 15 | # How to use 16 | in your activity xml : 17 | ```xml 18 | 27 | ``` 28 | In your class 29 | ```java 30 | AnimationBottomBar mAnimationBottomBar; 31 | mAnimationBottomBar = (AnimationBottomBar) findViewById(R.id.bottom); 32 | mAnimationBottomBar.addItem(new BottomItem(R.drawable.h, "one")) 33 | .addItem(new BottomItem(R.drawable.h, "two")) 34 | .addItem(new BottomItem(R.drawable.h, "three")) 35 | .addItem(new BottomItem(R.drawable.h, "four")) 36 | .addItem(new BottomItem(R.drawable.h, "five")) 37 | .build(); 38 | ``` 39 | Add itemSelectedListener 40 | ```java 41 | mAnimationBottomBar.setItemSelectListener(new AnimationBottomBar.OnItemSelectListener() { 42 | @Override 43 | public void onItemSelectListener(int position) { 44 | /*do something here*/ 45 | } 46 | }); 47 | ``` 48 | # License 49 | [Apache](http://www.apache.org/licenses/LICENSE-2.0.html) -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /bottombar/src/main/java/com/mran/bottombar/AnimationBottomBar.java: -------------------------------------------------------------------------------- 1 | package com.mran.bottombar; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.util.AttributeSet; 8 | import android.util.Log; 9 | import android.view.Gravity; 10 | import android.view.MotionEvent; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.view.animation.Animation; 14 | import android.view.animation.Transformation; 15 | import android.widget.ImageView; 16 | import android.widget.TextView; 17 | 18 | import java.util.ArrayList; 19 | 20 | /** 21 | * Created by M on 2017/8/20. 22 | */ 23 | 24 | public class AnimationBottomBar extends ViewGroup { 25 | private static final int CHILDCOUNTMAX = 5;//bottombar中能存在的item最大数; 26 | 27 | private ArrayList mBottomItemArrayList = new ArrayList<>(); 28 | private Paint mPaint = new Paint(); 29 | private Context mContext; 30 | private int itemCount;//item的数量 31 | private int childCount;//子view的数量 32 | private int barHeight;//bar的高度 33 | private int barWidth;//bar的宽度 34 | private int itemWidth;//平均每个item的宽度 35 | private int selectIndex = 0;//当前选中的位置 36 | private int selectLastIndex = 0;//上次选中的位置 37 | private float touchDownX;//记录手指第一次按下的X位置 38 | 39 | private int itemMoveLeft = 0;//item左边的位置 40 | private int itemMoveRight = 0;//item移动右边的位置 41 | private int itemMoveCenter = 0;//item移动中心的位置 42 | 43 | private int itemMoveLastLeft = 0;//上次item移动左边的位置 44 | private int itemMoveLastRight = 0;//上次item移动右边的位置 45 | private BottomAnimation mBottomAnimation = new BottomAnimation(); 46 | 47 | 48 | private int backGroundColor;//背景的颜色 49 | private float textSize; 50 | private int textColor; 51 | private int selectTextColor; 52 | private ArrayList mImageViews=new ArrayList<>(); 53 | private ArrayList mTextViews=new ArrayList<>(); 54 | private int[] itemcolors = {0xFFF93008, 0xFF73ADCE, 0xFFEDC15E, 0xFFDC6394, 0xFF6BCEB0};//记录每个item的颜色 55 | private int[] itemCenterX = {0, 0, 0, 0, 0};//记录每个item的中心位置 56 | private float[] itemScale = {0.5f, 0.5f, 0.5f, 0.5f, 0.5f};//记录每个item的缩放比例 57 | private OnItemSelectListener mOnItemSelectListener; 58 | private AttributeSet mAttributeSet; 59 | 60 | public AnimationBottomBar(Context context) { 61 | super(context); 62 | // init(context); 63 | } 64 | 65 | public AnimationBottomBar(Context context, AttributeSet attrs) { 66 | super(context, attrs); 67 | init(context, attrs); 68 | } 69 | 70 | public AnimationBottomBar(Context context, AttributeSet attrs, int defStyleAttr) { 71 | super(context, attrs, defStyleAttr); 72 | init(context, attrs); 73 | } 74 | 75 | 76 | private void init(Context context, AttributeSet attrs) { 77 | this.mContext = context; 78 | mAttributeSet = attrs; 79 | getAttrs(); 80 | setWillNotDraw(false);/*设置false之后才能调用ondraw()*/ 81 | mBottomAnimation.setDuration(300); 82 | 83 | mBottomAnimation.setAnimationListener(new Animation.AnimationListener() { 84 | @Override 85 | public void onAnimationStart(Animation animation) { 86 | 87 | } 88 | 89 | @Override 90 | public void onAnimationEnd(Animation animation) { 91 | clearAnimation(); 92 | itemMoveLastLeft = itemMoveLeft; 93 | itemMoveLastRight = itemMoveRight; 94 | selectLastIndex = selectIndex; 95 | 96 | Log.d("AnimationBottomBar", "onAnimationEnd:itemMoveLastRight " + itemMoveLastRight); 97 | } 98 | 99 | @Override 100 | public void onAnimationRepeat(Animation animation) { 101 | 102 | } 103 | }); 104 | } 105 | 106 | /*添加item*/ 107 | public AnimationBottomBar addItem(BottomItem bottomItem) { 108 | mBottomItemArrayList.add(bottomItem); 109 | return this; 110 | } 111 | 112 | 113 | public void build() throws Exception { 114 | itemCount = mBottomItemArrayList.size(); 115 | if (itemCount > CHILDCOUNTMAX) { 116 | throw new Exception("The maximum number of items is 5"); 117 | } 118 | itemWidth = getLayoutParams().width / itemCount; 119 | for (BottomItem bottomItem : mBottomItemArrayList) { 120 | ImageView imageView = new ImageView(mContext); 121 | imageView.setImageResource(bottomItem.drawableRes); 122 | mImageViews.add(imageView); 123 | addView(imageView, itemWidth, 20); 124 | } 125 | for (BottomItem bottomItem : mBottomItemArrayList) { 126 | TextView textView = new TextView(mContext); 127 | textView.setTextSize(textSize); 128 | textView.setText(bottomItem.title); 129 | textView.setTextColor(textColor); 130 | textView.setGravity(Gravity.CENTER); 131 | mTextViews.add(textView); 132 | addView(textView, itemWidth, 20); 133 | } 134 | 135 | Log.d("AnimationBottomBar", "build: itemwidth" + itemWidth); 136 | } 137 | 138 | /*手动选择选择的item*/ 139 | 140 | 141 | @Override 142 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 143 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 144 | childCount = getChildCount(); 145 | barWidth = getSize(300, widthMeasureSpec);/*bottombar的宽度*/ 146 | barHeight = getSize(300, heightMeasureSpec);/*--的高度*/ 147 | itemWidth = barWidth / itemCount; 148 | for (int i = 0; i < childCount; i++) { 149 | View childView = getChildAt(i); 150 | measureChild(childView, widthMeasureSpec, heightMeasureSpec); 151 | childView.getLayoutParams().width = itemWidth; 152 | } 153 | setSelectIndex(0); 154 | } 155 | 156 | private int getSize(int defaultSize, int measureSpec) { 157 | 158 | int mySize = defaultSize; 159 | int mode = MeasureSpec.getMode(measureSpec); 160 | int size = MeasureSpec.getSize(measureSpec); 161 | switch (mode) { 162 | case MeasureSpec.UNSPECIFIED: 163 | mySize = defaultSize; 164 | break; 165 | case MeasureSpec.AT_MOST: 166 | mySize = size; 167 | break; 168 | case MeasureSpec.EXACTLY: 169 | mySize = size; 170 | break; 171 | } 172 | return mySize; 173 | } 174 | 175 | @Override 176 | protected void onDraw(Canvas canvas) { 177 | 178 | //绘制item颜色 179 | for (int i = 0; i < 5; i++) { 180 | mPaint.setColor(itemcolors[i]); 181 | canvas.drawRect(itemWidth * i, 0, itemWidth * (i + 1), barHeight, mPaint); 182 | canvas.save(); 183 | } 184 | mPaint.setColor(backGroundColor); 185 | //画出背景,两个长方形 186 | canvas.drawRect(0, 0, itemMoveLeft, barHeight, mPaint); 187 | canvas.drawRect(itemMoveRight, 0, itemWidth * 5, barHeight, mPaint); 188 | canvas.save(); 189 | for (int i = 0; i < itemCount; i++) { 190 | int deltaX = Math.abs(itemMoveCenter - itemCenterX[i]);/*获得当前item移动中心点和item固定中心点的距离*/ 191 | if (deltaX < itemWidth) { 192 | itemScale[i] = (float) (-0.5 * deltaX / itemWidth + 1);/*当距离小于一个item的宽度时调整item的缩放系数*/ 193 | } else itemScale[i] = 0.5f;/*非选中的item的缩放系数固定为0.5*/ 194 | /*对item的大小进行调整*/ 195 | 196 | mImageViews.get(i).setScaleX(itemScale[i]); 197 | mImageViews.get(i).setScaleY(itemScale[i]); 198 | // View childTextView = getChildAt(itemCount + i); 199 | mTextViews.get(i).setScaleX(itemScale[i]); 200 | mTextViews.get(i).setScaleY(itemScale[i]); 201 | } 202 | super.onDraw(canvas); 203 | 204 | } 205 | 206 | 207 | @Override 208 | protected void onLayout(boolean changed, int l, int t, int r, int b) { 209 | 210 | 211 | for (int i = 0; i < itemCount; i++) {/*//遍历每一个item,放置item的位置*/ 212 | itemCenterX[i] = (int) (itemWidth * (i + 0.5));/*//记录每个item的中心位置*/ 213 | 214 | View childImageView = getChildAt(i); 215 | childImageView.layout(itemWidth * i, 0, itemWidth * (i + 1), 100); 216 | View childTextView = getChildAt(itemCount + i); 217 | childTextView.layout(itemWidth * i + childTextView.getWidth() / 4, 100, itemWidth * (i + 1), barHeight); 218 | 219 | } 220 | } 221 | 222 | 223 | @Override 224 | public boolean dispatchTouchEvent(MotionEvent ev) { 225 | int action = ev.getAction(); 226 | 227 | switch (action) { 228 | case MotionEvent.ACTION_DOWN: 229 | touchDownX = ev.getX(); 230 | break; 231 | case MotionEvent.ACTION_UP: 232 | if (ev.getX() / itemWidth == touchDownX / itemWidth) { 233 | selectIndex = (int) (ev.getX() / itemWidth); 234 | changeTitleColor(); 235 | 236 | sendListenerPosition(selectIndex); 237 | /*点击时开始动画*/ 238 | startAnimation(mBottomAnimation); 239 | } 240 | break; 241 | 242 | } 243 | return true; 244 | } 245 | 246 | private void changeTitleColor() { 247 | 248 | for (int i = 0; i < itemCount; i++) { 249 | if (i == selectIndex) { 250 | mTextViews.get(i).setTextColor(selectTextColor); 251 | } else { 252 | mTextViews.get(i).setTextColor(textColor); 253 | } 254 | } 255 | } 256 | 257 | private void getAttrs() { 258 | TypedArray typedArray = mContext.obtainStyledAttributes(mAttributeSet, R.styleable.AnimationBottomBar); 259 | 260 | 261 | backGroundColor = typedArray.getColor(R.styleable.AnimationBottomBar_backgruond, 0xFF5C4E71); 262 | textSize = typedArray.getDimension(R.styleable.AnimationBottomBar_textSize, 25.0f); 263 | textColor = typedArray.getColor(R.styleable.AnimationBottomBar_textColor, 0xffffff); 264 | selectTextColor = typedArray.getColor(R.styleable.AnimationBottomBar_selectTextColor, 0x639fff); 265 | Log.d("AnimationBottomBar", "getAttrs:textSize " + textSize); 266 | typedArray.recycle(); 267 | } 268 | 269 | /*发送点击监听*/ 270 | private void sendListenerPosition(int position) { 271 | if (mOnItemSelectListener != null) 272 | mOnItemSelectListener.onItemSelectListener(position); 273 | } 274 | 275 | public void setSelectIndex(int i) { 276 | selectIndex = i; 277 | itemMoveLeft = itemWidth * selectIndex; 278 | itemMoveRight = itemWidth * (selectIndex + 1); 279 | itemMoveLastRight = itemMoveRight; 280 | itemMoveLastLeft = itemMoveLeft; 281 | itemMoveCenter = itemMoveLeft + itemWidth / 2; 282 | selectLastIndex = i; 283 | postInvalidate(); 284 | } 285 | 286 | public AnimationBottomBar setItemSelectListener(OnItemSelectListener onItemSelectListener) { 287 | this.mOnItemSelectListener = onItemSelectListener; 288 | return this; 289 | } 290 | 291 | public interface OnItemSelectListener { 292 | void onItemSelectListener(int position); 293 | } 294 | 295 | private class BottomAnimation extends Animation { 296 | @Override 297 | protected void applyTransformation(float interpolatedTime, Transformation t) { 298 | super.applyTransformation(interpolatedTime, t); 299 | int position = selectIndex - selectLastIndex; 300 | /*判断不同方向的移动*/ 301 | if (position < 0) {/*向左滑动*/ 302 | itemMoveRight = (int) (itemMoveLastRight + interpolatedTime * itemWidth * position); 303 | itemMoveLeft = (int) (itemMoveLastLeft + setFirst(interpolatedTime) * itemWidth * position); 304 | itemMoveCenter = (int) (itemMoveLastRight + interpolatedTime * itemWidth * position) - itemWidth / 2;/*记录中心点移动的位置*/ 305 | } else {/*向右滑动*/ 306 | 307 | itemMoveRight = (int) (itemMoveLastRight + setFirst(interpolatedTime) * itemWidth * position); 308 | itemMoveLeft = (int) (itemMoveLastLeft + interpolatedTime * itemWidth * position); 309 | itemMoveCenter = (int) (itemMoveLastLeft + interpolatedTime * itemWidth * position) + itemWidth / 2;/*/记录中心点移动的位置*/ 310 | 311 | } 312 | postInvalidate(); 313 | } 314 | 315 | /*为了实现果冻效果,先移动的一侧要有快速效果*/ 316 | private float setFirst(float interpolatedTime) { 317 | return (float) Math.sin(interpolatedTime * 0.5 * Math.PI); 318 | } 319 | 320 | } 321 | 322 | 323 | } 324 | --------------------------------------------------------------------------------