Android学习笔记_56_应用Tween动画 (渐变、缩放、位移、旋转)

1、实现listview每个项先向右移动,再向左移动(回到原来位置)

TranslateAnimation ta = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f,

                                      Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f);

ta.setDuration(500);

view.startAnimation(ta);

  type:相对那个控件,value:移动多少。

2、让EditText抖动效果:shake.xml和cycle_7.xml

<?xml version="1.0" encoding="utf-8"?>

<translate xmlns:android="http://schemas.android.com/apk/res/android"

    android:duration="1000"

    android:fromXDelta="0"

    android:interpolator="@anim/cycle_7"

    android:toXDelta="10" />
<?xml version="1.0" encoding="utf-8"?>

<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"

    android:cycles="7" />

<!--重复执行7次-->
Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);

et_number.startAnimation(shake);//应用动画

 

 

你可能感兴趣的:(Android学习)