java - ObjectAnimator 之后的 AnimationDrawable 导致错误
问题描述
我试图在一个活动中发生两个动画,第一个动画首先发生,只有在完成后,第二个动画才会开始。ObjectAnimator 使用 .ofFloat() 方法将 imageView 在屏幕上向上移动,然后我想要一个加载动画,该动画循环遍历多个图像文件以创建类似加载的效果。
这是我的代码:
//Animations
final Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable()
{
@Override
public void run()
{
//Change cloud from sleeping to awake/happy
g2ndSleepingClouds.setBackgroundResource(R.drawable.clouds_happy_formatted);
//Move image view 250 pixels up the screen vertically
ObjectAnimator animation1 = ObjectAnimator.ofFloat(g2ndSleepingClouds, "translationY", -250f);
animation1.setDuration(1000);
animation1.start();
//Loading animation
loadingImageView.setBackgroundResource(R.drawable.loading_1);
loadingAnimation = (AnimationDrawable) loadingImageView.getBackground();
loadingAnimation.stop();
loadingAnimation.start();
}
}, 1000);
我在 Logcat 中得到的错误是:
“android.graphics.drawable.BitmapDrawable 不能转换为 android.graphics.drawable.AnimationDrawable”
有什么帮助吗?
解决方案
推荐阅读
- javascript - 我不断收到“无效的挂钩呼叫”。错误
- python - 如何从 groupby 数据框 pandas 中获取索引列表
- python-3.x - 为什么 `exec bash` 在 CI 管道中不起作用?
- javascript - 切换时如何防止我的容器变大?
- r - 如何使用 streamstats 包在 R 中描绘多个分水岭?
- python - 在python中使用正则表达式在一对或多对字符串之间获取文本
- discord - 如何制作 Discord 宏
- bluesnap - 如何在扩展支付 API 中覆盖价格
- flask - 在 Flask 路由中检查外部请求的请求标头和有效负载
- wordpress - WP_REST_Request 为自定义端点返回 rest_no_route (404)