这个很有趣的指标通过AnimCheckBox实现,下载地址:https://github.com/lguipeng/AnimCheckBox

代码:

activity_main.xml:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" > <!-- app:circle_color 点击后的背景颜色设置 -->
<!-- app:stroke_color 线条颜色和点击后的勾勾颜色设置 -->
<!-- app:stroke_width 线条宽度设置 --> <com.github.lguipeng.library.animcheckbox.AnimCheckBox
android:id="@+id/checkBox"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerInParent="true"
app:circle_color="#1976D2"
app:stroke_width="4dp" /> <Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/checkBox"
android:layout_centerHorizontal="true"
android:paddingTop="20dp"
android:text="button" /> </RelativeLayout>

MainActivity.java:

 package com.zzw.testanimcheckbox;

 import com.github.lguipeng.library.animcheckbox.AnimCheckBox;
import com.github.lguipeng.library.animcheckbox.AnimCheckBox.OnCheckedChangeListener; import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast; public class MainActivity extends Activity {
private boolean temp=true;
private AnimCheckBox checkBox;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); checkBox = (AnimCheckBox) findViewById(R.id.checkBox);
// 设置默认显示为勾还是圈
checkBox.setChecked(temp); checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onChange(boolean checked) {
if(checked==true){
Toast.makeText(getApplicationContext(), "true", 0).show();
}else{
Toast.makeText(getApplicationContext(), "false", 0).show();
}
}
});
findViewById(R.id.button).setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
if(temp==true){
temp=false;
}else{
temp=true;
}
//当点击按钮判断值temp变化了的时候,checkBox的随之变化,并且显示出动画效果,
//后面如果是false的话,动画就不会显示,并且画面不会出现变化
checkBox.setChecked(temp,true);
}
});
}
}

有趣的checkbox动画切换状态(支付宝转账成功显示)--第三方开源--AnimCheckBox的更多相关文章

  1. 动画气泡指示当前滑动值--第三方开源--DiscreteSeekbar

    DiscreteSeekbar在github上的项目主页是:https://github.com/AnderWeb/discreteSeekBar DiscreteSeekbar可以自定制的属性很多, ...

  2. 使用jQuery 中的显示与隐藏动画效果实现折叠下拉菜单的收缩和展开,在页面的列表中有若干项,列表的每项中有一个二级列表,二级列表默认为隐藏状态。点击列表的项,切换二级列表的显示或隐藏状态

    查看本章节 查看作业目录 需求说明: 使用jQuery 中的显示与隐藏动画效果实现折叠下拉菜单的收缩和展开,在页面的列表中有若干项,列表的每项中有一个二级列表,二级列表默认为隐藏状态.点击列表的项,切 ...

  3. android fragment+ FragmentTabHost+viewpager 切换状态不保存的问题

    转载请注明出处:http://blog.csdn.net/djy1992/article/details/46674169 @author dujinyang 难得有时间上来写博客. fragment ...

  4. 纯css实现checkbox开关切换按钮

    我们都知道 checkbox 标签默认样式 实在是太low了,故对CheckBox美化很有必要. 现提供两种方式对其进行美化. 方法一 <div class="switch-wrap ...

  5. (转)利用 SVG 和 CSS3 实现有趣的边框动画

    目录 SVG 学习<一>基础图形及线段 SVG 学习<二>进阶 SVG世界,视野,视窗 stroke属性 svg分组 SVG 学习<三>渐变 SVG 学习<四 ...

  6. Unity---动画系统学习(4)---使用混合树(Blend Tree)来实现走、跑、转弯等的动画切换

    1. 介绍 Blend Tree用于多个动画之间的混合,比如走到跑的切换.转弯的切换. 如果用动画学习笔记(3)中的方法,需要新建很多的状态,不仅麻烦,而且切换状态时也很容易不流畅. 而Blend T ...

  7. Activity左边滑出,右边滑入的动画切换

    Activity左边滑出,右边滑入的动画切换 转载请注明出处:http://blog.csdn.net/u012301841/article/details/46920809 大家都知道Android ...

  8. JS框架_(JQuery.js)文章全屏动画切换

    百度云盘 传送门 密码:anap 文章全屏动画切换效果 <!doctype html> <html lang="zh"> <head> < ...

  9. jQuery鼠标悬停内容动画切换效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

随机推荐

  1. UVa OJ 10071

    Problem B Back to High School Physics Input: standard input Output: standard output A particle has i ...

  2. uiview 的setAnimationTransition : forView 方法实现翻页效果

    [UIView beginAnimations:nil context:nil]; [UIView setAnimationTransition:UIViewAnimationTransitionCu ...

  3. java如何判断字符串是否为空的方法

    以下是java 判断字符串是否为空的四种方法: 方法一: 最多人使用的一个方法, 直观, 方便, 但效率很低: if(s == null ||"".equals(s)); 方法二: ...

  4. 【python,threading】python多线程

    使用多线程的方式 1.  函数式:使用threading模块threading.Thread(e.g target name parameters) import time,threading def ...

  5. oneThink 数据库连接失败,总提示密码不对的解决办法

    oneThink的数据库配置文件是\Application\Common\Conf\config.php,按理来说,在这里修改数据库配置应该就可以重新连接,可是不管我怎么修改密码总是和我设置的不一致, ...

  6. how to build a paper's architecture?

    1. problem? what's the problem? then do some extension of the problem. 2. related works ,which means ...

  7. Differential Geometry之第四章标架与曲面论的基本定理

    第四章.标架与曲面论的基本定理 1.活动标架 2.自然标架的运动方程 爱因斯坦求和约定(Einstein summation convention) 3.曲面的结构方程 4.曲面的存在唯一性定理 5. ...

  8. Macbook之用brew安装Python

    1. brew install python 2.If you don't have ~/.bash_profile, add ~/.bash_profile by touch ~/.bash_pro ...

  9. django 学习-18 用户管理Auth系统使用

    1.首先跟之前说的admin的要求有点像, vim urls.py from django.contrib import adminadmin.autodiscover()               ...

  10. C#的Process类的一些用法

    c#之process类相关整理 一.根据进程名获取进程的用户名? 需要添加对 System.Management.dll 的引用 using System.Diagnostics; using Sys ...