0
希望我不是在这里重复一个问题;我找不到多个ViewPropertyAnimators
。目标是在8秒钟内从y1到y2生成一个视图。在第一秒淡出,然后在最后一秒淡出。多个ViewPropertyAnimators
以下是我在已经尽了活动的onCreate()
:
final View animatingView = findViewById(R.id.animateMe);
animatingView.post(new Runnable() {
@Override
public void run() {
//Translation
animatingView.setY(0);
animatingView.animate().translationY(800).setDuration(8000);
//Fading view in
animatingView.setAlpha(0f);
animatingView.animate().alpha(1f).setDuration(1000);
//Waiting 6 seconds and then fading the view back out
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
animatingView.animate().alpha(0f).setDuration(1000);
}
}, 6000);
}
});
但是,结果是翻译从0到800,和阿尔法从0到1的所有在一秒钟。然后6秒后视图淡出。它看起来每次我调用View.animate()它返回相同的ViewPropertyAnimator。有没有办法让我可以有多个?我正在考虑将视图的alpha设置为动画,将视图嵌套在相对布局中,然后对相关的布局转换进行动画处理。如果我不需要,我宁愿不走那条路。有谁知道更好的解决方案?