TextView跑马灯效果
布局里:
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
activity里:
pao.setSelected(true);
属性动画 垂直下降
cil2.animate().translationY(500)
.setDuration(500)
.withStartAction(new Runnable() {
@Override
public void run() {
//动画开始
}
})
.withEndAction(new Runnable() {
@Override
public void run() {
//动画结束
Toast.makeText(MainActivity.this, "动画结束", Toast.LENGTH_SHORT).show();
}
}).start();
属性动画 对角线下落
ValueAnimator valueAnimator = new ValueAnimator();
valueAnimator.setDuration(3000);
valueAnimator.setObjectValues(new PointF(0, 0));
valueAnimator.setEvaluator(new TypeEvaluator<PointF>()
{
@Override
public PointF evaluate(float fraction, PointF startValue,
PointF endValue)
{
PointF point = new PointF();
point.x = 200 * fraction * 3;
point.y = 0.5f * 200 * (fraction * 3) * (fraction * 3);
return point;
}
});
valueAnimator.start();
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
{
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
PointF point = (PointF) animation.getAnimatedValue();
cil2.setX(point.x);
cil2.setY(point.y);
}
});
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
Toast.makeText(MainActivity.this, "动画停止了", Toast.LENGTH_SHORT).show();
}
});