Android中属性动画4----ValueAnimator拿到每一次变化的值
来源:互联网 发布:sql server 排序规则 编辑:程序博客网 时间:2024/06/06 06:35
代码:
Main4Activity
activity_main4.xmlpackage com.zhh.android;import android.animation.Animator;import android.animation.AnimatorListenerAdapter;import android.animation.ValueAnimator;import android.app.Activity;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.view.animation.LinearInterpolator;import android.widget.Button;/** * ValueAnimator的使用,拿到每一次变化的值 */public class Main4Activity extends Activity { private Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main4); button = (Button) findViewById(R.id.button);// 按钮点击事件 button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {// 设置0到100的整数变化 final ValueAnimator valueAnimator = ValueAnimator.ofInt(0,10);// 整个事件段是5秒 valueAnimator.setDuration(10000);// 数字均匀变化,也可设置其他的变化方式,先快后慢,先慢后快等...... valueAnimator.setInterpolator(new LinearInterpolator());// 监听每次改变时的值 valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) {// 拿到每一次变化的值 Integer value = (Integer) animation.getAnimatedValue();// 把只设置到按钮上 button.setText(value+""); } }); valueAnimator.start(); } }); }}<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.zhh.android.Main4Activity" android:orientation="vertical" > <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮" android:layout_centerInParent="true" /></RelativeLayout>参考视频:http://www.imooc.com/learn/263
源码下载:
http://download.csdn.net/download/zhaihaohao1/10126123
阅读全文
0 0
- Android中属性动画4----ValueAnimator拿到每一次变化的值
- android 属性动画(ValueAnimator)
- Android属性动画 ValueAnimator
- android ValueAnimator 属性动画的用法
- android 动画 属性动画 ValueAnimator
- Android属性动画之ValueAnimator
- Android属性动画之ValueAnimator
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Android内存之VSS/RSS/PSS/USS
- Linux Support for ARM LPAE 分析
- 一老一小保险参保时间
- arm处理器bank与存储器的bank详解
- linux的swapper_pg_dir
- Android中属性动画4----ValueAnimator拿到每一次变化的值
- kernel中常规内存映射区物现地址与虚拟地址转换
- 页面过大导致PDF转Word失败的解决方法
- Linux Kernel系列一:开篇和Kernel启动概要
- Linux Kernel 系列二:用户空间的初始化
- Linux Kernel系列三:Kernel编译和链接中的linker script(vmlinux.lds.S)语法详解
- linux kernel系列四:嵌入式系统中的文件系统以及MTD
- 深入理解SELinux SEAndroid 之一
- 深入理解SELinux SEAndroid之二