zoukankan      html  css  js  c++  java
  • ObjectAnimator ValueAnimator AnimatorSet基础

    package com.xbing.com.viewdemo;

    import android.animation.AnimatorSet;
    import android.animation.ObjectAnimator;
    import android.animation.ValueAnimator;
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.RadioButton;
    import android.widget.TextView;

    /**
    * Created by zhaobing on 2016/6/21.
    */
    public class AnimatorActivity extends Activity {

    TextView mView;
    RadioButton mSelect;

    public int index = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.animator_activity);
    mView = (TextView) findViewById(R.id.tv_animator);
    mSelect = (RadioButton)findViewById(R.id.rb_select);

    findViewById(R.id.btn_move).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
    ObjectAnimator animator = new ObjectAnimator();
    switch (index%7){
    case 0:
                  //透明度渐变
    animator = ObjectAnimator.ofFloat(mView,"alpha",1f,0f,1f);
    break;
    case 1://横向平移
    animator = ObjectAnimator.ofFloat(mView,"translationX",0,100,0);
    break;
    case 2://旋转
    animator = ObjectAnimator.ofFloat(mView,"rotation",0,180,0);
    break;
    case 3://依Y轴旋转
    animator = ObjectAnimator.ofFloat(mView,"rotationY",0,180,0);
    break;
    case 4://竖向平移
    animator = ObjectAnimator.ofFloat(mView,"translationY",0,100,0);
    break;
    case 5://竖向缩放
    animator = ObjectAnimator.ofFloat(mView,"scaleY",0,3,1);
    break;
    case 6://几个动画合并
    animator = ObjectAnimator.ofFloat(mView,"alpha",1f,0f,1f);
    ValueAnimator animator1 = ObjectAnimator.ofFloat(mView,"rotation",0,180,0);
    ObjectAnimator animator2 = ObjectAnimator.ofFloat(mView,"scaleY",0,3,1);
    ObjectAnimator animator3 = ObjectAnimator.ofFloat(mView,"scaleX",0,3,1);

                  //几个动画合并播放
    AnimatorSet animSet = new AnimatorSet();
    animSet.play(animator1).with(animator).with(animator2).with(animator3);
    animSet.setDuration(2000);
    animSet.start();
    break;

    }
    if(index%7<6){
    animator.setDuration(1000);
    animator.start();
    }

    if(!mSelect.isChecked()){
    index++;
    }


    }
    });
    }
    }
  • 相关阅读:
    python近期遇到的一些面试问题(一)
    python selenium 三种等待方式详解
    Nginx的ip_hash指令
    Nginx Tengine ngx_http_upstream_check_module 健康功能检测使用
    一个奇怪的网络故障 默认网关为0.0.0.0(Windows)
    win2003 server的域用户加入本地管理员组
    linux 添加secondary ip
    亚马逊云VPS AWS更改LINUX为ROOT权限密码登陆
    亚马逊云EC2做PPTP SERVER的笔记
    Linux性能分析 vmstat基本语法
  • 原文地址:https://www.cnblogs.com/x-bing/p/5602906.html
Copyright © 2011-2022 走看看