├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── github │ │ └── chengang │ │ └── tickview │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── chengang │ │ │ └── tickview │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.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 │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── github │ └── chengang │ └── tickview │ └── ExampleUnitTest.java ├── art └── tick_view_animation.gif ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── github │ │ └── chengang │ │ └── library │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── chengang │ │ │ └── library │ │ │ ├── DisplayUtil.java │ │ │ ├── OnCheckedChangeListener.java │ │ │ ├── TickAnimatorListener.java │ │ │ ├── TickRateEnum.java │ │ │ ├── TickView.java │ │ │ └── TickViewConfig.java │ └── res │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── github │ └── chengang │ └── library │ └── ExampleUnitTest.java └── settings.gradle /.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/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 urchankong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TickView 2 | 一个精致的打钩小动画,模仿轻芒杂志标记已读的动画 3 | 4 | 5 | ## 效果图 6 | ![](http://upload-images.jianshu.io/upload_images/956714-54cdce326517b896.gif?imageMogr2/auto-orient/strip) 7 | 8 | ## 使用 9 | 10 | ### Step 1 11 | ``` gradle 12 | allprojects { 13 | repositories { 14 | ... 15 | maven { url 'https://www.jitpack.io' } 16 | } 17 | } 18 | ``` 19 | 20 | ### Step 2 21 | ``` gradle 22 | dependencies { 23 |    compile 'com.github.ChengangFeng:TickView:v1.0.2' 24 | } 25 | ``` 26 | 27 | ### Step 3 28 | 29 | #### xml配置 30 | ``` xml 31 | 37 | ``` 38 | 39 | #### 点击事件回调 40 | ``` java 41 | tickView.setOnCheckedChangeListener(new TickView.OnCheckedChangeListener() { 42 | @Override 43 | public void onCheckedChanged(TickView tickView, boolean isCheck) { 44 | //do something here 45 | } 46 | }); 47 | ``` 48 | 49 | #### 模拟点击效果 50 | ``` java 51 | tickView.toggle(); 52 | ``` 53 | 54 | #### 手动更改控件状态 55 | ``` java 56 | tickView.setChecked(true); 57 | ``` 58 | 59 | ## 思路实现 60 | * 简书,[http://www.jianshu.com/p/673e3b3715a2](http://www.jianshu.com/p/1b2cdba03d23) 61 | * 掘金,[https://juejin.im/post/59ebe2b75188250989513b1b](https://juejin.im/post/59ebe2b75188250989513b1b) 62 | 63 | ## 优化思路 64 | * 简书,[http://www.jianshu.com/p/1ff14c0156b0](http://www.jianshu.com/p/1ff14c0156b0) 65 | * 掘金,[https://juejin.im/post/59f5609851882534af2538c0](https://juejin.im/post/59f5609851882534af2538c0) 66 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.2" 6 | defaultConfig { 7 | applicationId "com.github.chengang.tickview" 8 | minSdkVersion 19 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:26.+' 28 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 29 | testCompile 'junit:junit:4.12' 30 | // compile 'com.github.ChengangFeng:TickView:v1.0.2' 31 | compile project(path: ':library') 32 | } 33 | -------------------------------------------------------------------------------- /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 D:\chengang\Android\AndroidSDK/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/androidTest/java/com/github/chengang/tickview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.github.chengang.tickview; 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.github.chengang.tickview", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/chengang/tickview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.chengang.tickview; 2 | 3 | import android.graphics.Color; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.util.Log; 7 | import android.view.View; 8 | import android.widget.Toast; 9 | 10 | import com.github.chengang.library.OnCheckedChangeListener; 11 | import com.github.chengang.library.TickAnimatorListener; 12 | import com.github.chengang.library.TickView; 13 | 14 | public class MainActivity extends AppCompatActivity { 15 | 16 | private static final String TAG = MainActivity.class.getSimpleName(); 17 | 18 | TickView tickView; 19 | TickView tickViewAccent; 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_main); 25 | tickView = (TickView) findViewById(R.id.tick_view); 26 | tickView.getConfig().setOnCheckedChangeListener(new OnCheckedChangeListener() { 27 | @Override 28 | public void onCheckedChanged(TickView tickView, boolean isCheck) { 29 | 30 | } 31 | }).setTickAnimatorListener(new TickAnimatorListener.TickAnimatorListenerAdapter() { 32 | @Override 33 | public void onAnimationStart(TickView tickView) { 34 | super.onAnimationStart(tickView); 35 | } 36 | }); 37 | 38 | 39 | tickViewAccent = (TickView) findViewById(R.id.tick_view_accent); 40 | findViewById(R.id.check_btn).setOnClickListener(new View.OnClickListener() { 41 | @Override 42 | public void onClick(View view) { 43 | tickView.setChecked(true); 44 | tickViewAccent.setChecked(true); 45 | } 46 | }); 47 | findViewById(R.id.uncheck_btn).setOnClickListener(new View.OnClickListener() { 48 | @Override 49 | public void onClick(View view) { 50 | tickView.setChecked(false); 51 | tickViewAccent.setChecked(false); 52 | } 53 | }); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 21 | 22 | 25 | 26 | 32 | 33 | 34 | 35 | 41 | 42 |