Kop*_*ppo 5 animation android translation frame
对所有人来说
我有动画图像和帧动画,我正在从视图后面移动到屏幕上.TranslateAnimation完成后,我想保持结束位置,因此setFillAfter设置为true.
我的问题是TranslateAnimation完成后帧动画停止.如何重新启动或保持帧动画?
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
id="selected" android:oneshot="false">
<item android:drawable="@drawable/a" android:duration="200" />
<item android:drawable="@drawable/b" android:duration="200" />
<item android:drawable="@drawable/c" android:duration="200" />
</animation-list>
loadingView = (RelativeLayout) findViewById(R.id.loadingBar);
loadingView.setVisibility(View.VISIBLE);
loadingImage = (ImageView) loadingView.findViewById(R.id.loading);
loadingImage.setBackgroundResource(R.drawable.loading);
animateImages = (AnimationDrawable) loadingImage.getBackground();
translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF,0.0f, Animation.RELATIVE_TO_SELF, -1.0f);
translateAnimation.setInterpolator(new AccelerateInterpolator());
translateAnimation.setDuration(2000);
translateAnimation.setFillEnabled(true);
translateAnimation.setFillAfter(true);
translateAnimation.setAnimationListener(new AnimationListener()
{
@Override
public void onAnimationStart(Animation animation)
{
// TODO Auto-generated method stub
animateImages.start();
}
@Override
public void onAnimationEnd(Animation arg0)
{
}
@Override
public void onAnimationRepeat(Animation animation)
{
// TODO Auto-generated method stub
}
});
loadingView.startAnimation(translateAnimation);
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,但找不到明确的解决方案。因此,我的一个解决方法是在最后添加一个长动画,几乎没有任何更改(翻译动画在很长一段时间后仅移动几个像素),因此逐帧动画会在几分钟内继续播放。对于我的应用程序来说这已经足够了。也许您会发现这个想法很有用。
| 归档时间: |
|
| 查看次数: |
1289 次 |
| 最近记录: |