├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── dictionaries │ └── Administrator.xml ├── scopes │ └── scope_settings.xml ├── encodings.xml ├── vcs.xml ├── libraries │ ├── nineoldandroids_lib.xml │ ├── support_v4_20_0_0.xml │ ├── support_annotations_20_0_0.xml │ └── appcompat_v7_20_0_0.xml ├── modules.xml ├── misc.xml ├── gradle.xml └── compiler.xml ├── app ├── .gitignore ├── libs │ └── nineoldandroids-lib.jar ├── src │ └── main │ │ ├── ic_launcher-web.png │ │ ├── res │ │ ├── drawable-hdpi │ │ │ ├── add.png │ │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ │ ├── add.png │ │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ │ ├── add.png │ │ │ └── ic_launcher.png │ │ ├── drawable-xxhdpi │ │ │ ├── add.png │ │ │ └── ic_launcher.png │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── styles.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── attrs.xml │ │ ├── drawable │ │ │ └── circle_background.xml │ │ ├── anim │ │ │ └── slide_out_bottom.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ ├── menu │ │ │ ├── main.xml │ │ │ └── circle_canvas_demo1.xml │ │ └── layout │ │ │ ├── activity_main.xml │ │ │ ├── activity_meteor.xml │ │ │ └── activity_circle_canvas_demo1.xml │ │ ├── java │ │ └── com │ │ │ └── etong │ │ │ └── canvasview_master │ │ │ └── app │ │ │ ├── AnimUtil.java │ │ │ ├── CircleDrawable.java │ │ │ ├── Circle.java │ │ │ ├── MainActivity.java │ │ │ ├── MeteorActivity.java │ │ │ ├── CircleCanvasDemo1.java │ │ │ ├── MyCircle.java │ │ │ ├── ArcTranslateAnimation.java │ │ │ ├── CircleCanvasLayout.java │ │ │ └── CircleCanvasView.java │ │ └── AndroidManifest.xml ├── build.gradle ├── proguard-rules.txt └── app.iml ├── settings.gradle ├── .gitignore ├── screenshots ├── canvasLayout.gif └── canvasLayout1.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md ├── .gitattributes ├── gradle.properties ├── CanvasView-master.iml ├── gradlew.bat └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | CanvasView-master -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /screenshots/canvasLayout.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/screenshots/canvasLayout.gif -------------------------------------------------------------------------------- /screenshots/canvasLayout1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/screenshots/canvasLayout1.gif -------------------------------------------------------------------------------- /app/libs/nineoldandroids-lib.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/app/libs/nineoldandroids-lib.jar -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.idea/dictionaries/Administrator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/app/src/main/res/drawable-hdpi/add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/app/src/main/res/drawable-mdpi/add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/app/src/main/res/drawable-xhdpi/add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/app/src/main/res/drawable-xxhdpi/add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyWallace/CanvasView-master/HEAD/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #e8520f 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Aug 12 09:42:40 CST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip 7 | -------------------------------------------------------------------------------- /.idea/libraries/nineoldandroids_lib.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/circle_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CanvasView-master 2 | ================= 3 | 4 | 画个圈圈诅咒你 5 | 仿android L其中一种动画特效。 6 | 7 | 效果图 8 | 9 | ![image](https://raw.githubusercontent.com/RoyWallace/CanvasView-master/master/screenshots/canvasLayout.gif) 10 | 11 | 效果图2 12 | 13 | ![image](https://raw.githubusercontent.com/RoyWallace/CanvasView-master/master/screenshots/canvasLayout1.gif) 14 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_out_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CanvasView-master 5 | Hello world! 6 | Settings 7 | CircleCanvasDemo1 8 | MainActivity 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/menu/circle_canvas_demo1.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/etong/canvasview_master/app/AnimUtil.java: -------------------------------------------------------------------------------- 1 | package com.etong.canvasview_master.app; 2 | 3 | /** 4 | * Created by Administrator on 14-8-8. 5 | */ 6 | public class AnimUtil { 7 | 8 | public static long calcBezier(float interpolatedTime, float p0, float p1, float p2) { 9 | return Math.round((Math.pow((1 - interpolatedTime), 2) * p0) 10 | + (2 * (1 - interpolatedTime) * interpolatedTime * p1) 11 | + (Math.pow(interpolatedTime, 2) * p2)); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.idea/libraries/support_v4_20_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/support_annotations_20_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/libraries/appcompat_v7_20_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android' 2 | 3 | android { 4 | compileSdkVersion 20 5 | buildToolsVersion '20' 6 | 7 | defaultConfig { 8 | minSdkVersion 20 9 | targetSdkVersion 20 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | runProguard false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile 'com.android.support:appcompat-v7:20+' 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile files('libs/nineoldandroids-lib.jar') 25 | } 26 | -------------------------------------------------------------------------------- /app/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:/Program Files (x86)/Android/android-studio19/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the ProGuard 5 | # include property in project.properties. 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 | #} -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Settings specified in this file will override any Gradle settings 5 | # configured through the IDE. 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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /CanvasView-master.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/etong/canvasview_master/app/CircleDrawable.java: -------------------------------------------------------------------------------- 1 | package com.etong.canvasview_master.app; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.ColorFilter; 5 | import android.graphics.Paint; 6 | import android.graphics.drawable.Animatable; 7 | import android.graphics.drawable.Drawable; 8 | 9 | /** 10 | * Created by Administrator on 2014/8/27. 11 | */ 12 | public class CircleDrawable extends Drawable implements Animatable { 13 | 14 | public int cx; 15 | public int cy; 16 | public int radius; 17 | public Paint paint; 18 | 19 | private boolean running = false; 20 | 21 | 22 | public CircleDrawable(){ 23 | 24 | } 25 | 26 | @Override 27 | public void start() { 28 | running = true; 29 | 30 | } 31 | 32 | @Override 33 | public void stop() { 34 | running = false; 35 | 36 | } 37 | 38 | @Override 39 | public boolean isRunning() { 40 | return running; 41 | } 42 | 43 | @Override 44 | public void draw(Canvas canvas) { 45 | canvas.drawCircle(cx,cy,radius,paint); 46 | } 47 | 48 | @Override 49 | public void setAlpha(int i) { 50 | 51 | } 52 | 53 | @Override 54 | public void setColorFilter(ColorFilter colorFilter) { 55 | 56 | } 57 | 58 | @Override 59 | public int getOpacity() { 60 | return 0; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/etong/canvasview_master/app/Circle.java: -------------------------------------------------------------------------------- 1 | package com.etong.canvasview_master.app; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.graphics.PointF; 7 | import android.util.Log; 8 | import android.view.View; 9 | 10 | /** 11 | * Created by Administrator on 14-8-8. 12 | */ 13 | public class Circle { 14 | 15 | 16 | private float cx; 17 | 18 | private float cy; 19 | 20 | private float radius; 21 | 22 | private Paint paint; 23 | 24 | public Circle(float cx, float cy, float radius, Paint paint) { 25 | this.cx = cx; 26 | this.cy = cy; 27 | this.radius = radius; 28 | this.paint = paint; 29 | } 30 | 31 | public void draw(Canvas canvas) { 32 | canvas.drawCircle(cx, cy, radius, paint); 33 | } 34 | 35 | public void moveTo(float interpolatedTime, float startX, float endX, float startY, float endY) { 36 | this.cx = AnimUtil.calcBezier(interpolatedTime, startX, startX, endX); 37 | this.cy = AnimUtil.calcBezier(interpolatedTime, startY, endY, endY); 38 | } 39 | 40 | public void Zoom(float fromR,float toR,float time) { 41 | float increase = Math.abs(toR-fromR)/time; 42 | this.radius = radius + increase; 43 | } 44 | 45 | public void Zoom(float radius) { 46 | this.radius = radius; 47 | } 48 | 49 | public float getCx() { 50 | return cx; 51 | } 52 | 53 | public void setCx(float cx) { 54 | this.cx = cx; 55 | } 56 | 57 | public float getCy() { 58 | return cy; 59 | } 60 | 61 | public void setCy(float cy) { 62 | this.cy = cy; 63 | } 64 | 65 | public float getRadius() { 66 | return radius; 67 | } 68 | 69 | public void setRadius(float radius) { 70 | this.radius = radius; 71 | } 72 | 73 | public Paint getPaint() { 74 | return paint; 75 | } 76 | 77 | public void setPaint(Paint paint) { 78 | this.paint = paint; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/com/etong/canvasview_master/app/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.etong.canvasview_master.app; 2 | 3 | import android.app.ListActivity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.view.Menu; 7 | import android.view.MenuItem; 8 | import android.view.View; 9 | import android.widget.ArrayAdapter; 10 | import android.widget.ListView; 11 | 12 | 13 | public class MainActivity extends ListActivity { 14 | 15 | private String [] str = {"CircleCanvasBase","CircleCanvas with ImageView"}; 16 | 17 | public MainActivity getThis(){ 18 | return MainActivity.this; 19 | } 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(android.R.layout.list_content); 25 | 26 | ListView listView = getListView(); 27 | listView.setAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1,str)); 28 | } 29 | 30 | @Override 31 | protected void onListItemClick(ListView l, View v, int position, long id) { 32 | switch (position){ 33 | 34 | case 0: 35 | goToActivity(CircleCanvasDemo1.class); 36 | break; 37 | case 1: 38 | goToActivity(MeteorActivity.class); 39 | break; 40 | } 41 | } 42 | 43 | @Override 44 | public boolean onCreateOptionsMenu(Menu menu) { 45 | 46 | // Inflate the menu; this adds items to the action bar if it is present. 47 | getMenuInflater().inflate(R.menu.main, menu); 48 | return true; 49 | } 50 | 51 | @Override 52 | public boolean onOptionsItemSelected(MenuItem item) { 53 | // Handle action bar item clicks here. The action bar will 54 | // automatically handle clicks on the Home/Up button, so long 55 | // as you specify a parent activity in AndroidManifest.xml. 56 | int id = item.getItemId(); 57 | if (id == R.id.action_settings) { 58 | return true; 59 | } 60 | return super.onOptionsItemSelected(item); 61 | } 62 | 63 | public void goToActivity(Class c){ 64 | Intent intent = new Intent(this,c); 65 | startActivity(intent); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /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_meteor.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 16 | 17 | 24 | 25 | 33 | 34 | 42 | 43 | 51 | 52 | 53 | 54 | 55 | 67 | 68 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /app/src/main/java/com/etong/canvasview_master/app/MeteorActivity.java: -------------------------------------------------------------------------------- 1 | package com.etong.canvasview_master.app; 2 | 3 | import android.support.v7.app.ActionBarActivity; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | import android.view.Menu; 7 | import android.view.MenuItem; 8 | import android.view.View; 9 | import android.view.animation.AnimationSet; 10 | import android.widget.Button; 11 | import android.widget.ImageButton; 12 | import android.widget.ImageView; 13 | 14 | import com.nineoldandroids.animation.Animator; 15 | import com.nineoldandroids.animation.AnimatorSet; 16 | import com.nineoldandroids.animation.ObjectAnimator; 17 | 18 | public class MeteorActivity extends ActionBarActivity implements View.OnClickListener { 19 | 20 | private CircleCanvasView circleCanvas; 21 | 22 | private ImageView rb; 23 | 24 | private ImageView imageView; 25 | 26 | private ImageButton imageButton; 27 | 28 | private ImageButton imageButton2; 29 | 30 | AnimatorSet animatorSet; 31 | 32 | @Override 33 | protected void onCreate(Bundle savedInstanceState) { 34 | super.onCreate(savedInstanceState); 35 | setContentView(R.layout.activity_meteor); 36 | 37 | findAllView(); 38 | 39 | setupAnim(); 40 | 41 | setAlllistener(); 42 | } 43 | 44 | private void findAllView() { 45 | 46 | rb = (ImageView) findViewById(R.id.imageView2); 47 | 48 | imageView = (ImageView) findViewById(R.id.imageView); 49 | 50 | imageButton = (ImageButton) findViewById(R.id.imageButton); 51 | imageButton2 = (ImageButton) findViewById(R.id.imageButton2); 52 | 53 | circleCanvas = (CircleCanvasView) findViewById(R.id.view); 54 | circleCanvas.setMeteor(rb); 55 | // circleCanvas.setKnockPoint(200,100); 56 | // circleCanvas.setStarNumber(2); 57 | } 58 | 59 | private void setupAnim() { 60 | ObjectAnimator xAnimator = ObjectAnimator.ofFloat(rb, "translationX", -100f); 61 | ObjectAnimator yAnimator = ObjectAnimator.ofFloat(rb, "translationY", 100f); 62 | 63 | animatorSet = new AnimatorSet(); 64 | animatorSet.setDuration(500); 65 | animatorSet.playTogether(xAnimator,yAnimator); 66 | 67 | } 68 | 69 | private void setAlllistener(){ 70 | rb.setOnClickListener(this); 71 | } 72 | 73 | 74 | @Override 75 | public boolean onCreateOptionsMenu(Menu menu) { 76 | 77 | // Inflate the menu; this adds items to the action bar if it is present. 78 | getMenuInflater().inflate(R.menu.main, menu); 79 | return true; 80 | } 81 | 82 | @Override 83 | public boolean onOptionsItemSelected(MenuItem item) { 84 | // Handle action bar item clicks here. The action bar will 85 | // automatically handle clicks on the Home/Up button, so long 86 | // as you specify a parent activity in AndroidManifest.xml. 87 | int id = item.getItemId(); 88 | if (id == R.id.action_settings) { 89 | circleCanvas.ZoomOut(); 90 | return true; 91 | } 92 | return super.onOptionsItemSelected(item); 93 | } 94 | 95 | @Override 96 | public void onClick(View view) { 97 | if(view == rb){ 98 | Log.i("etong","click"); 99 | circleCanvas.startMeteorAnim(); 100 | } 101 | } 102 | 103 | @Override 104 | public void onBackPressed() { 105 | // super.onBackPressed(); 106 | circleCanvas.ZoomOut(); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /app/src/main/java/com/etong/canvasview_master/app/CircleCanvasDemo1.java: -------------------------------------------------------------------------------- 1 | package com.etong.canvasview_master.app; 2 | 3 | import android.app.Activity; 4 | import android.support.v7.app.ActionBarActivity; 5 | import android.os.Bundle; 6 | import android.view.Menu; 7 | import android.view.MenuItem; 8 | import android.view.View; 9 | import android.widget.Button; 10 | 11 | public class CircleCanvasDemo1 extends Activity implements View.OnClickListener{ 12 | 13 | 14 | private CircleCanvasLayout circleCanvasLayout; 15 | 16 | private Button btn,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10,backBtn; 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_circle_canvas_demo1); 22 | 23 | findAllView(); 24 | setListener(); 25 | } 26 | 27 | private void findAllView() { 28 | circleCanvasLayout = (CircleCanvasLayout) findViewById(R.id.view); 29 | btn = (Button) findViewById(R.id.button); 30 | btn2 = (Button) findViewById(R.id.button2); 31 | btn3 = (Button) findViewById(R.id.button3); 32 | btn4 = (Button) findViewById(R.id.button4); 33 | btn5 = (Button) findViewById(R.id.button5); 34 | btn6 = (Button) findViewById(R.id.button6); 35 | btn7 = (Button) findViewById(R.id.button7); 36 | btn8 = (Button) findViewById(R.id.button8); 37 | btn9 = (Button) findViewById(R.id.button9); 38 | btn10 = (Button) findViewById(R.id.button10); 39 | backBtn = (Button) findViewById(R.id.back_btn); 40 | 41 | } 42 | 43 | private void setListener(){ 44 | btn.setOnClickListener(this); 45 | btn2.setOnClickListener(this); 46 | btn3.setOnClickListener(this); 47 | btn4.setOnClickListener(this); 48 | btn5.setOnClickListener(this); 49 | btn6.setOnClickListener(this); 50 | btn7.setOnClickListener(this); 51 | btn8.setOnClickListener(this); 52 | btn9.setOnClickListener(this); 53 | btn10.setOnClickListener(this); 54 | backBtn.setOnClickListener(this); 55 | } 56 | 57 | 58 | @Override 59 | public boolean onCreateOptionsMenu(Menu menu) { 60 | 61 | // Inflate the menu; this adds items to the action bar if it is present. 62 | getMenuInflater().inflate(R.menu.circle_canvas_demo1, menu); 63 | return true; 64 | } 65 | 66 | @Override 67 | public boolean onOptionsItemSelected(MenuItem item) { 68 | // Handle action bar item clicks here. The action bar will 69 | // automatically handle clicks on the Home/Up button, so long 70 | // as you specify a parent activity in AndroidManifest.xml. 71 | int id = item.getItemId(); 72 | if (id == R.id.action_settings) { 73 | return true; 74 | } 75 | return super.onOptionsItemSelected(item); 76 | } 77 | 78 | @Override 79 | public void onClick(View view) { 80 | if(view == btn){ 81 | circleCanvasLayout.ZoomIn(); 82 | }else if(view ==btn2){ 83 | circleCanvasLayout.setCirclePosition(CircleCanvasLayout.LEFT_TOP); 84 | }else if(view ==btn3){ 85 | circleCanvasLayout.setCirclePosition(CircleCanvasLayout.LEFT_CENTER); 86 | }else if(view ==btn4){ 87 | circleCanvasLayout.setCirclePosition(CircleCanvasLayout.LEFT_BOTTOM); 88 | }else if(view ==btn5){ 89 | circleCanvasLayout.setCirclePosition(CircleCanvasLayout.CENTER_TOP); 90 | }else if(view ==btn6){ 91 | circleCanvasLayout.setCirclePosition(CircleCanvasLayout.CENTER); 92 | }else if(view ==btn7){ 93 | circleCanvasLayout.setCirclePosition(CircleCanvasLayout.CENTER_BOTTOM); 94 | }else if(view ==btn8){ 95 | circleCanvasLayout.setCirclePosition(CircleCanvasLayout.RIGHT_TOP); 96 | }else if(view ==btn9){ 97 | circleCanvasLayout.setCirclePosition(CircleCanvasLayout.RIGHT_CENTER); 98 | }else if(view ==btn10){ 99 | circleCanvasLayout.setCirclePosition(CircleCanvasLayout.RIGHT_BOTTOM); 100 | }else if(view ==backBtn){ 101 | circleCanvasLayout.ZoomOut(); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /app/src/main/java/com/etong/canvasview_master/app/MyCircle.java: -------------------------------------------------------------------------------- 1 | package com.etong.canvasview_master.app; 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.View; 10 | import android.view.ViewGroup; 11 | import android.widget.RelativeLayout; 12 | 13 | /** 14 | * Created by Administrator on 14-8-5. 15 | */ 16 | public class MyCircle extends RelativeLayout { 17 | 18 | private Paint paint; 19 | 20 | public final static int black = 0x70000000;//黑色 21 | 22 | public final static int white = 0xddffffff;//白色 23 | 24 | public int orange; 25 | 26 | private int minRadius; 27 | 28 | private int radius; 29 | 30 | private int cx; 31 | 32 | private int cy; 33 | 34 | public int increase; 35 | 36 | private boolean animAble = false; 37 | 38 | private boolean wtf = false; 39 | 40 | public MyCircle(Context context) { 41 | super(context); 42 | init(); 43 | } 44 | 45 | public MyCircle(Context context, AttributeSet attrs) { 46 | super(context, attrs); 47 | init(); 48 | } 49 | 50 | private void initAttrs(Context context, AttributeSet attrs) { 51 | 52 | } 53 | 54 | private void init() { 55 | 56 | orange = getResources().getColor(R.color.orange); 57 | 58 | setWillNotDraw(false); 59 | 60 | float density = getResources().getDisplayMetrics().density; 61 | 62 | minRadius = 0; 63 | 64 | increase = (int) (10 * density); 65 | 66 | paint = new Paint(); 67 | paint.setColor(orange); 68 | paint.setAntiAlias(true);//抗锯齿 69 | 70 | } 71 | 72 | /** 73 | * 设置画笔颜色 74 | * 75 | * @param color 76 | */ 77 | public void setColor(int color) { 78 | paint.setColor(color); 79 | } 80 | 81 | /** 82 | * 获取画笔颜色 83 | * 84 | * @return 85 | */ 86 | public int getColor() { 87 | return paint.getColor(); 88 | } 89 | 90 | @Override 91 | protected void onLayout(boolean changed, int l, int t, int r, int b) { 92 | super.onLayout(changed, l, t, r, b); 93 | //确保view的高宽和定位已经初始化完成,然后才开始动画 94 | animAble = true; 95 | } 96 | 97 | @Override 98 | protected void onDraw(Canvas canvas) { 99 | super.onDraw(canvas); 100 | if (!isInEditMode()) { 101 | canvas.drawCircle(getCx(), getCy(), radius, paint); 102 | } 103 | } 104 | 105 | /** 106 | * 获取圈圈圆点x坐标 107 | * 108 | * @return 109 | */ 110 | public int getCx() { 111 | return (getRight() - getLeft()) / 2; 112 | } 113 | 114 | /** 115 | * 获取圈圈圆点y坐标 116 | * 117 | * @return 118 | */ 119 | public int getCy() { 120 | return (getBottom() - getTop()) / 2; 121 | } 122 | 123 | public void setCX(int cx) { 124 | this.cx = cx; 125 | } 126 | 127 | public void setCY(int cy) { 128 | this.cy = cy; 129 | } 130 | 131 | 132 | public void drawCircle() { 133 | new Thread(new Runnable() { 134 | @Override 135 | public void run() { 136 | 137 | //如果View高宽位置未初始化完成,线程等待 138 | while (!animAble) { 139 | try { 140 | Thread.sleep(200); 141 | } catch (Exception e) { 142 | e.printStackTrace(); 143 | } 144 | } 145 | 146 | //开始动画 147 | for (int i = minRadius; i < getDiagonal(); i = i + increase) { 148 | try { 149 | Thread.sleep(20); 150 | radius = i; 151 | // paint.setColor(getResources().getColor(android.R.color.transparent)); 152 | postInvalidate(); 153 | } catch (Exception e) { 154 | e.printStackTrace(); 155 | } 156 | } 157 | 158 | } 159 | }).start(); 160 | } 161 | 162 | /** 163 | * 获取对角线粗略估算 164 | * 165 | * @return 166 | */ 167 | public int getDiagonal() { 168 | return (getHeight() + getWidth()) / 2; 169 | } 170 | 171 | } 172 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_circle_canvas_demo1.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 21 | 22 |