package com.loaderman.customviewdemo;

import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView; public class MainActivity extends AppCompatActivity {
private Button mButton;
private TextView mTv, mTv2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTv = (TextView)findViewById(R.id.tv);
findViewById(R.id.start_anim).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
PropertyValuesHolder rotationHolder = PropertyValuesHolder.ofFloat("Rotation", 60f, -60f, 40f, -40f, -20f, 20f, 10f, -10f, 0f);
PropertyValuesHolder alphaHolder = PropertyValuesHolder.ofFloat("alpha", 0.1f, 1f, 0.1f, 1f);
ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mTv, rotationHolder, alphaHolder);\\实例入口
animator.setDuration(3000);
animator.start();
}
});
}
}

PropertyValuesHolder的ofFloat和ofInt函数的基本用法


package com.loaderman.customviewdemo;

import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.animation.AccelerateInterpolator; public class MainActivity extends AppCompatActivity {
private MyTextView mTv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTv = findViewById(R.id.mTv);
findViewById(R.id.start_anim).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
/**
* ofObject使用
*/
PropertyValuesHolder charHolder = PropertyValuesHolder.ofObject("CharText",new CharEvaluator(),new Character('A'),new Character('Z'));
ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mTv, charHolder);
animator.setDuration(3000);
animator.setInterpolator(new AccelerateInterpolator());
animator.start();
}
});
}
}
package com.loaderman.customviewdemo;

import android.content.Context;
import android.util.AttributeSet; public class MyTextView extends android.support.v7.widget.AppCompatTextView {
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setCharText(Character character){
setText(String.valueOf(character));
}
}
package com.loaderman.customviewdemo;

import android.animation.TypeEvaluator;

public class CharEvaluator implements TypeEvaluator<Character> {
public Character evaluate(float fraction, Character startValue, Character endValue) {
int startInt = (int)startValue;
int endInt = (int)endValue;
int curInt = (int)(startInt + fraction *(endInt - startInt));
char result = (char)curInt;
return result;
}
}

PropertyValuesHolder的ofobject函数的基本用法

效果:

PropertyValuesHolder学习的更多相关文章

  1. Android之动画的学习(转载)

    Android动画学习笔记-Android Animation   3.0以前,android支持两种动画模式,tween animation,frame animation,在android3.0中 ...

  2. Android Animation学习(五) ApiDemos解析:容器布局动画 LayoutTransition

    Android Animation学习(五) ApiDemos解析:容器布局动画 LayoutTransition Property animation系统还提供了对ViewGroup中的View改变 ...

  3. Android Animation学习(四) ApiDemos解析:多属性动画

    Android Animation学习(四) ApiDemos解析:多属性动画 如果想同时改变多个属性,根据前面所学的,比较显而易见的一种思路是构造多个对象Animator , ( Animator可 ...

  4. Android动画学习笔记-Android Animation

    Android动画学习笔记-Android Animation   3.0以前,android支持两种动画模式,tween animation,frame animation,在android3.0中 ...

  5. android动画学习

    android动画学习   转载自:http://www.open-open.com/lib/view/open1329994048671.html 3.0以前,android支持两种动画模式,twe ...

  6. 从直播编程到直播教育:LiveEdu.tv开启多元化的在线学习直播时代

    2015年9月,一个叫Livecoding.tv的网站在互联网上引起了编程界的注意.缘于Pingwest品玩的一位编辑在上网时无意中发现了这个网站,并写了一篇文章<一个比直播睡觉更奇怪的网站:直 ...

  7. Angular2学习笔记(1)

    Angular2学习笔记(1) 1. 写在前面 之前基于Electron写过一个Markdown编辑器.就其功能而言,主要功能已经实现,一些小的不影响使用的功能由于时间关系还没有完成:但就代码而言,之 ...

  8. ABP入门系列(1)——学习Abp框架之实操演练

    作为.Net工地搬砖长工一名,一直致力于挖坑(Bug)填坑(Debug),但技术却不见长进.也曾热情于新技术的学习,憧憬过成为技术大拿.从前端到后端,从bootstrap到javascript,从py ...

  9. 消息队列——RabbitMQ学习笔记

    消息队列--RabbitMQ学习笔记 1. 写在前面 昨天简单学习了一个消息队列项目--RabbitMQ,今天趁热打铁,将学到的东西记录下来. 学习的资料主要是官网给出的6个基本的消息发送/接收模型, ...

随机推荐

  1. Python_while语句

    1.while语句: count = 0 while (count<4): count +=1 print('准备放入第'+str(count)+'个杯子') 注:还是要注意一下,条件之后加“: ...

  2. springboot ElasticSearch 简单的全文检索高亮

    原文:https://segmentfault.com/a/1190000017324038?utm_source=tag-newest 首先引入依赖 <dependency> <g ...

  3. Spring Aop织入点语法

    Aspectj织入点语法: 1.execution(public * *(..))   任何类的任何返回值的任何方法 2.execution(* set*(..))       任何类的set开头的方 ...

  4. linux网络编程之socket编程(十四)

    经过令国鸡冻的APEC会之后,北京的冬天终于不冷了,有暖气的日子就是倍儿爽呀~~洗完热水澡,舒服的躺在床上欢乐地敲打着键盘,是件多么幸福的事呀,好了,抒发情感后,正题继续. 上节中已经初步学习了UDP ...

  5. 在cmd运行窗口运行.py文件

    步骤

  6. Javascript基础(1)

    1 Javascript介绍 1.1 js是一款运行在客户端的网页编程语言 1.2 组成部分 (1)ECMAScript:ECMAScript不是一门语言,而是一个标准.符合这个标准的比较常见的有:J ...

  7. java中为什么不能通过getClass().getName()获取父类的类名

    例如: class A{} public class B extends A{ public void test(){ System.out.println(super.getClass().getN ...

  8. CentOS环境部署(Nginx+Mariadb+Java+Tomcat)

    1.安装nginx 安装 yum install nginx 启动 yum install nginx 开机自启 sudo systemctl enable nginx 2.安装mariadb 安装 ...

  9. 转,sql 50道练习题

    SQL语句50题   -- 一.创建教学系统的数据库,表,以及数据 --student(sno,sname,sage,ssex) 学生表--course(cno,cname,tno) 课程表--sc( ...

  10. 012_Python3 斐波纳契数列 + end 关键字

    1.个斐波纳契数列. #!/usr/bin/python3   # Fibonacci series: 斐波纳契数列 # 两个元素的总和确定了下一个数 a, b = 0, 1 while b < ...