繁体   English   中英

在继续其余代码之前,等待ImageView.animate()结束

[英]Waiting for ImageView.animate() to end before proceeding with the rest of the code

我是学习android开发的初学者,我试图使用ImageView.animate()。alpha()使用淡入和淡出动画进行图像切换。 我发现图像在动画完成之前发生了变化,因此看不到动画。

我的代码是

  ImageView image = (ImageView)findViewById(R.id.imageToChange); image.animate().alpha(0f).setDuration(1000); image.setImageResource(R.drawable.image2); 

预先感谢,马特

为了等待动画结束,您可以使用Android网站setListener方法中的示例

如果要使视图可见,则需要设置alpha(1f) 另外,请在动画之前尝试setImageResource (将3切换为2)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM