├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_live.png │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_happy_red_16.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_white_flash_128.png │ │ │ ├── mipmap-hdpi │ │ │ │ ├── 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 │ │ │ ├── drawable-anydpi │ │ │ │ ├── ic_happy_white_32.png │ │ │ │ ├── anim_square_play.xml │ │ │ │ ├── arrow_anim.xml │ │ │ │ ├── ic_icon_square.xml │ │ │ │ ├── anim_helix_play.xml │ │ │ │ ├── anim_beauty_circle_play.xml │ │ │ │ ├── arrow.xml │ │ │ │ ├── anim_three_point_loading.xml │ │ │ │ └── ic_svg_beauty_circle.xml │ │ │ ├── drawable │ │ │ │ ├── ripple_red.xml │ │ │ │ ├── anim_arrow_bank_play.xml │ │ │ │ ├── ic_svg_icon_helix.xml │ │ │ │ ├── ic_svg_three_point.xml │ │ │ │ └── ic_svg_arrow_right_bank.xml │ │ │ ├── animator │ │ │ │ ├── anim_translate_top_iii.xml │ │ │ │ ├── anim_translate_right_i.xml │ │ │ │ ├── anim_path_start.xml │ │ │ │ ├── anim_fivestar.xml │ │ │ │ ├── anim_left.xml │ │ │ │ ├── anim_right.xml │ │ │ │ ├── anim_color_turn_red_fill.xml │ │ │ │ ├── anim_translate_top.xml │ │ │ │ ├── anim_path_end.xml │ │ │ │ ├── anim_translate_top_i.xml │ │ │ │ ├── anim_translate_top_ii.xml │ │ │ │ ├── anim_color_turn_red.xml │ │ │ │ └── anim_square_to_helix.xml │ │ │ └── layout │ │ │ │ ├── activity_test_anim.xml │ │ │ │ ├── activity_path_measure.xml │ │ │ │ ├── activity_bezier.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── activity_vector.xml │ │ │ │ └── activity_lollipop.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── rayhahah │ │ │ │ └── advancedanim │ │ │ │ ├── MainFragment.java │ │ │ │ ├── bezier │ │ │ │ ├── BezierUtil.java │ │ │ │ ├── DrawPathView.java │ │ │ │ ├── BezierActivity.java │ │ │ │ ├── SecondBezierView.java │ │ │ │ ├── ThirdBezierView.java │ │ │ │ ├── BallRollView.java │ │ │ │ └── WaveView.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── pathmeasure │ │ │ │ ├── PathMeasureActivity.java │ │ │ │ └── PathMeasureView.java │ │ │ │ ├── vector │ │ │ │ └── VectorActivity.java │ │ │ │ └── lollipop │ │ │ │ ├── LollipopActivity.java │ │ │ │ └── TestAnimActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── rayhahah │ │ │ └── advancedanim │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── rayhahah │ │ └── advancedanim │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── .idea ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── kotlinc.xml ├── inspectionProfiles │ ├── profiles_settings.xml │ └── Project_Default.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml ├── compiler.xml └── misc.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── README.md ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AdvancedAnim 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rayhahah/AdvancedAnim/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_live.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rayhahah/AdvancedAnim/HEAD/app/src/main/res/mipmap-mdpi/ic_live.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rayhahah/AdvancedAnim/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rayhahah/AdvancedAnim/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rayhahah/AdvancedAnim/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_happy_red_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rayhahah/AdvancedAnim/HEAD/app/src/main/res/mipmap-mdpi/ic_happy_red_16.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rayhahah/AdvancedAnim/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rayhahah/AdvancedAnim/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rayhahah/AdvancedAnim/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/Rayhahah/AdvancedAnim/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_white_flash_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rayhahah/AdvancedAnim/HEAD/app/src/main/res/mipmap-mdpi/ic_white_flash_128.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rayhahah/AdvancedAnim/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/Rayhahah/AdvancedAnim/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/Rayhahah/AdvancedAnim/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-anydpi/ic_happy_white_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rayhahah/AdvancedAnim/HEAD/app/src/main/res/drawable-anydpi/ic_happy_white_32.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 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ripple_red.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 30 20:35:12 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #6a46ff 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AdvancedAnim 2 | Android动画进阶使用Demo 3 | 4 | ## VectorDrawable的使用 5 | 参照我的简述博客[VectorDrawable动画进阶](http://www.jianshu.com/p/e71978a6cffa) 6 | 7 | ## PathMeasure的使用 8 | 参照我的简书博客[PathMeasure动画进阶](http://www.jianshu.com/p/4b440fca400a) 9 | 10 | ## Lollipop中动画的使用 11 | 参照我的简书博客[Lollipop动画进阶](http://www.jianshu.com/p/04db6ddae20f) 12 | -------------------------------------------------------------------------------- /app/src/main/res/animator/anim_translate_top_iii.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/animator/anim_translate_right_i.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/rayhahah/advancedanim/MainFragment.java: -------------------------------------------------------------------------------- 1 | package com.rayhahah.advancedanim; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v7.app.AppCompatDelegate; 5 | 6 | /** 7 | * Created by a on 2017/3/30. 8 | */ 9 | 10 | public class MainFragment extends Fragment { 11 | 12 | static { 13 | AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/res/animator/anim_path_start.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/animator/anim_fivestar.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-anydpi/anim_square_play.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-anydpi/arrow_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 10 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/animator/anim_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/animator/anim_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/animator/anim_color_turn_red_fill.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/animator/anim_translate_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/animator/anim_path_end.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-anydpi/ic_icon_square.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/test/java/com/rayhahah/advancedanim/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.rayhahah.advancedanim; 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/main/res/animator/anim_translate_top_i.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/animator/anim_translate_top_ii.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/animator/anim_color_turn_red.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-anydpi/anim_helix_play.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/animator/anim_square_to_helix.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-anydpi/anim_beauty_circle_play.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | 10 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/anim_arrow_bank_play.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 13 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-anydpi/arrow.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_svg_icon_helix.xml: -------------------------------------------------------------------------------- 1 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.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/res/drawable-anydpi/anim_three_point_loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 15 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /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=-Xmx1024m 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/androidTest/java/com/rayhahah/advancedanim/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.rayhahah.advancedanim; 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.rayhahah.advancedanim", 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 E:\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/drawable/ic_svg_three_point.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-anydpi/ic_svg_beauty_circle.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | //apply plugin : 表示Gradle所引入的插件 2 | //这里表示该module是一个Android Application,插件里面有Android相关的一切工具 3 | apply plugin: 'com.android.application' 4 | 5 | //android : 描述了当前Android module构建过程所用到的所有参数 6 | android { 7 | //目标版本号 8 | compileSdkVersion 25 9 | //编译工具版本号 10 | 11 | buildToolsVersion "25.0.2" 12 | //默认配置 13 | defaultConfig { 14 | applicationId "com.rayhahah.advancedanim" 15 | minSdkVersion 19 16 | targetSdkVersion 25 17 | versionCode 1 18 | versionName "1.0" 19 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 20 | vectorDrawables.useSupportLibrary = true 21 | } 22 | //构建配置 23 | buildTypes { 24 | release { 25 | minifyEnabled false 26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 27 | } 28 | } 29 | } 30 | //dependencies : 当前Android Module构建过程中所依赖的所有库 31 | dependencies { 32 | compile fileTree(dir: 'libs', include: ['*.jar']) 33 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 34 | exclude group: 'com.android.support', module: 'support-annotations' 35 | }) 36 | compile 'com.android.support:appcompat-v7:25.2.0' 37 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 38 | compile 'com.ashokvarma.android:bottom-navigation-bar:1.3.0' 39 | testCompile 'junit:junit:4.12' 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_svg_arrow_right_bank.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 13 | 14 | 15 | 16 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_test_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 21 | 22 | 30 | 31 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/rayhahah/advancedanim/bezier/BezierUtil.java: -------------------------------------------------------------------------------- 1 | package com.rayhahah.advancedanim.bezier; 2 | 3 | import android.graphics.PointF; 4 | 5 | /** 6 | * Created by a on 2017/4/2. 7 | */ 8 | 9 | public class BezierUtil { 10 | 11 | 12 | /** 13 | * 根据起始点,控制点,终止点坐标和曲线长度比例获取曲线上点的坐标 14 | * 15 | * @param t 曲线长度比例 16 | * @param p0 起始点 17 | * @param p1 控制点 18 | * @param p2 终止点 19 | * @return t对应的点 20 | */ 21 | public static PointF CalculateBezierPointForQuadratic(float t, PointF p0, PointF p1, PointF p2) { 22 | PointF point = new PointF(); 23 | float temp = 1 - t; 24 | point.x = temp * temp * p0.x + 2 * t * temp * p1.x + t * t * p2.x; 25 | point.y = temp * temp * p0.y + 2 * t * temp * p1.y + t * t * p2.y; 26 | return point; 27 | } 28 | 29 | /** 30 | * 根据起始点,控制点,终止点坐标和曲线长度比例获取曲线上点的坐标 * 31 | * 32 | * @param t 曲线长度比例 33 | * @param p0 起始点 34 | * @param p1 控制点1 35 | * @param p2 控制点2 36 | * @param p3 终止点 37 | * @return t对应的点 38 | */ 39 | public static PointF CalculateBezierPointForCubic(float t, PointF p0, PointF p1, PointF p2, PointF p3) { 40 | PointF point = new PointF(); 41 | float temp = 1 - t; 42 | point.x = p0.x * temp * temp * temp + 3 * p1.x * t * temp * temp + 3 * p2.x * t * t * temp + p3.x * t * t * t; 43 | point.y = p0.y * temp * temp * temp + 3 * p1.y * t * temp * temp + 3 * p2.y * t * t * temp + p3.y * t * t * t; 44 | return point; 45 | } 46 | 47 | 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_path_measure.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 21 | 22 | 30 | 31 | 38 | 39 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/rayhahah/advancedanim/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.rayhahah.advancedanim; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | import android.widget.Button; 8 | 9 | import com.rayhahah.advancedanim.bezier.BezierActivity; 10 | import com.rayhahah.advancedanim.lollipop.LollipopActivity; 11 | import com.rayhahah.advancedanim.pathmeasure.PathMeasureActivity; 12 | import com.rayhahah.advancedanim.vector.VectorActivity; 13 | 14 | public class MainActivity extends AppCompatActivity { 15 | 16 | 17 | private Button btnVector; 18 | private Button btnBezier; 19 | private Button btnPathmeasure; 20 | private Button btnLollipop; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_main); 26 | 27 | initView(); 28 | } 29 | 30 | 31 | public void doClick(View view) { 32 | switch (view.getId()) { 33 | case R.id.btn_vector: 34 | startActivity(new Intent(this, VectorActivity.class)); 35 | break; 36 | case R.id.btn_bezier: 37 | startActivity(new Intent(this, BezierActivity.class)); 38 | break; 39 | case R.id.btn_pathmeasure: 40 | startActivity(new Intent(this, PathMeasureActivity.class)); 41 | break; 42 | case R.id.btn_lollipop: 43 | startActivity(new Intent(this, LollipopActivity.class)); 44 | break; 45 | 46 | } 47 | 48 | } 49 | 50 | private void initView() { 51 | btnVector = (Button) findViewById(R.id.btn_vector); 52 | btnBezier = (Button) findViewById(R.id.btn_bezier); 53 | btnPathmeasure = (Button) findViewById(R.id.btn_pathmeasure); 54 | btnLollipop = (Button) findViewById(R.id.btn_lollipop); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_bezier.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 18 | 19 | 26 | 27 | 33 | 34 | 40 | 41 | 47 | 48 | 49 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/rayhahah/advancedanim/pathmeasure/PathMeasureActivity.java: -------------------------------------------------------------------------------- 1 | package com.rayhahah.advancedanim.pathmeasure; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.widget.CompoundButton; 6 | import android.widget.ToggleButton; 7 | 8 | import com.rayhahah.advancedanim.R; 9 | 10 | public class PathMeasureActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener { 11 | 12 | private PathMeasureView pathMeasureView; 13 | private ToggleButton tbNormal; 14 | private ToggleButton tbWindow; 15 | private ToggleButton tbArrow; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_path_measure); 21 | initView(); 22 | } 23 | 24 | private void initView() { 25 | pathMeasureView = (PathMeasureView) findViewById(R.id.pathMeasureView); 26 | tbNormal = (ToggleButton) findViewById(R.id.tb_normal); 27 | tbWindow = (ToggleButton) findViewById(R.id.tb_window); 28 | tbArrow = (ToggleButton) findViewById(R.id.tb_arrow); 29 | tbNormal.setOnCheckedChangeListener(this); 30 | tbWindow.setOnCheckedChangeListener(this); 31 | tbArrow.setOnCheckedChangeListener(this); 32 | } 33 | 34 | 35 | @Override 36 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 37 | switch (buttonView.getId()) { 38 | case R.id.tb_normal: 39 | if (isChecked) { 40 | pathMeasureView.startAnim(); 41 | } else { 42 | pathMeasureView.pauseAnim(); 43 | } 44 | 45 | break; 46 | case R.id.tb_window: 47 | if (isChecked) { 48 | pathMeasureView.setWindow(true); 49 | } else { 50 | pathMeasureView.setWindow(false); 51 | } 52 | break; 53 | 54 | case R.id.tb_arrow: 55 | 56 | if (isChecked) { 57 | pathMeasureView.setArrow(true); 58 | } else { 59 | pathMeasureView.setArrow(false); 60 | } 61 | 62 | break; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/rayhahah/advancedanim/vector/VectorActivity.java: -------------------------------------------------------------------------------- 1 | package com.rayhahah.advancedanim.vector; 2 | 3 | import android.graphics.drawable.Animatable; 4 | import android.graphics.drawable.AnimatedVectorDrawable; 5 | import android.graphics.drawable.Drawable; 6 | import android.os.Bundle; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.support.v7.app.AppCompatDelegate; 9 | import android.view.View; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | 13 | import com.rayhahah.advancedanim.R; 14 | 15 | public class VectorActivity extends AppCompatActivity { 16 | 17 | static { 18 | //设置Activity支持5.0以下版本兼容VectorDrawable 19 | AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); 20 | 21 | } 22 | 23 | private TextView textView; 24 | private TextView tvPath; 25 | private TextView tvSet; 26 | private TextView tvStar; 27 | 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | setContentView(R.layout.activity_vector); 32 | initView(); 33 | } 34 | 35 | public void doClick(View view) { 36 | 37 | /** 38 | * 这个主要针对pathData路径变化 39 | * 只支持5.0以上的版本 40 | */ 41 | if (view.getId() == R.id.tv_path) { 42 | AnimatedVectorDrawable vectorDrawable = (AnimatedVectorDrawable) getDrawable(R.drawable.anim_square_play); 43 | ((TextView) view).setCompoundDrawables(null, vectorDrawable, null, null); 44 | vectorDrawable.start(); 45 | } else { 46 | 47 | /** 48 | * TextView中获取资源并启动 49 | */ 50 | if (view instanceof TextView) { 51 | Drawable[] drawables = ((TextView) view).getCompoundDrawables(); 52 | ((Animatable) drawables[1]).start(); 53 | } 54 | 55 | /** 56 | * ImageView中获取资源并启动 57 | */ 58 | if (view instanceof ImageView) { 59 | ((Animatable) ((ImageView) view).getDrawable()).start(); 60 | } 61 | } 62 | } 63 | 64 | private void initView() { 65 | textView = (TextView) findViewById(R.id.textView); 66 | tvPath = (TextView) findViewById(R.id.tv_path); 67 | tvSet = (TextView) findViewById(R.id.tv_set); 68 | tvStar = (TextView) findViewById(R.id.tv_star); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /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/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 17 | 18 | 25 | 26 |