Let's say an ImageView width and height is set to match_parent and wrap_content respectively in the layout file. Something like this:
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Then we access it in the java file:
ImageView image = (ImageView) findViewById(R.id.image);
Then we create an animation:
Animation anim = new AlphaAnimation(0, 1);
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
}
Then we attach the animation in the ImageView:
image.startAnimation(anim);
Now this will not work, right? Since I believe the ImageView is empty (does not have a height, so the animation will not work and the onAnimationEnd will never be called)
But when I added the following line, the onAnimationEnd works!
setImageBitmap(null)
Upon checking the dimension of the view, the height is set to 1px.
Now, does this mean Animation only works when the the view has at least 1px of dimension (for both width and height)?
I tried to trace Android source code but I got lost somewhere and wasn't able to comprehend what is going on in the View, ImageView and Animation classes.
Can anyone shed some light regarding this? Thanks in advance.