作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 Android 应用程序中,当我单击其中任何一个所有图像都具有动画效果时,我有五个 ImageView 。我为所有图像设置了缩小和放大动画。动画完成后,所选 ImageView 将不可见。图像不可见后,当我单击该 ImageView 位置时,它再次启动动画并且图像不可见。
放大动画:
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="1"
android:toXScale="5"
android:fromYScale="1"
android:toYScale="5"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"
android:fillAfter="true">
</scale>
缩小动画
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="5"
android:toXScale="1"
android:fromYScale="5"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"
android:fillAfter="true">
</scale>
zoomin =AnimationUtils.loadAnimation(this, R.anim.zoom);
zoomout=AnimationUtils.loadAnimation(this, R.anim.zoomout);
ImageView v2 = (ImageView) findViewById(R.id.image2);
v2.setOnClickListener(new View.OnClickListener()
{
@Override public void onClick(View v)
{
v2.setAnimation(zoomin);
v2.startAnimation(zoomin);
v2.setAnimation(zoomout);
v2.startAnimation(zoomout);
v2.clearAnimation();
}
});
最佳答案
将此代码添加到您的动画对象中:
animation.setAnimationListener(new AnimationListener()
{
@Override
public void onAnimationStart(Animation animation) { }
@Override
public void onAnimationRepeat(Animation animation) { }
@Override
public void onAnimationEnd(Animation animation)
{
v2.setImageResource(R.drawable.some_transparent_image);
}
});
关于java - 如何在android中动画结束后隐藏图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19921968/
我是一名优秀的程序员,十分优秀!