你应该尝试使用Android动画类编写自己的自定义动画。这是一个库链接,你可以根据需要进行学习和修改。它包含了像爆炸、折叠等动画。
https://github.com/2359media/EasyAndroidAnimations
对于你的问题,第一个动画有点难。它需要遮罩才能实现像上面展示的完美动画。如果你想要一些简单的提示,可以尝试使用两张黑色的图片,如下所示。确保用黑色部分覆盖整个屏幕。然后将一张图像向下移动,另一张向右移动以创建效果。
![horizontal bar](https://istack.dev59.com/Y5blo.webp)
![vertical bar](https://istack.dev59.com/SbDOm.webp)
第二个动画非常简单,您可以尝试以下提示中的内容:
<framelayout>
<imageview src="@drawable/car.jpg">
<linearlayout
weightsum="9"
orientation="horizontal"><!--set it's width height to cover car image-->
<imageview @+id="imgview1"
weight="1" src="@drawable/blackbar.jpg">
<imageview @+id="imgview2"
weight="1" src="@drawable/blackbar.jpg">
.
.
<imageview @+id="imgview9"
weight="1" src="drawable/blackbar.jpg">
</linearlayout>
</framelayout>
在您的Java代码中,尝试使用以下动画效果来显示黑色条纹。
new Timer().schedule(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
ScaleAnimation anim = new ScaleAnimation(1.0f, 0.0f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF,0.0f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setFillAfter(true);
anim.setDuration(400);
imgBlackBar1.startAnimation(anim);
}
});
}
}, 150);
现在,根据您的需求,为bar2设置300ms的延迟,为bar3设置450ms的延迟等等。