In my android application I have five imageviews when I click any one of that all images are animating. I set the zoomout and Zoomin animation for all the images. once the animation is finished, the selected image view is invisible. After image invisible, when i click on that imageview location it again start the animation and the image is invisible.
<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>
Add this code to your animation objects:
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);
}
});
This issue is occuring because you added android:fillAfter="true" in both Animation XML files.
Either remove "android:fillAfter="true" from both XMLs or keep " android:fillAfter="false" in both files.
you have to handle the animation listener for that animation.
zoomin.setAnimationListener(new AnimationListener()
{
@Override
public void onAnimationStart(Animation animation) { }
@Override
public void onAnimationRepeat(Animation animation) { }
@Override
public void onAnimationEnd(Animation animation)
{
v2.setVisibility(View.GONE);
}
});
You need to use a Transparent Image All you need to do is when your Animation ends you need to set a transparent Image as background/scr of that image thereby replacing the previous one.
Changing the visibility of view won't solve your problem
v2.setVisibility(View.GONE);
v2.setVisibility(View.INVISIBLE);
As both above lead to make your view non-clickable and you won't be able to click again.
您可以简单地更改图层的透明度。
v2.setAlpha(0f);
你必须首先使用 image.clearAnimation() 然后隐藏它 image.visibility = View.GONE
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.