A (175)

(Tuis.) #1

386 CHAPTER 10: Android Animation: Making Your UI Designs Move


Figure 10-26. The second ImageButton event handler configured to remove the background and start the animation


Since imageButtonTwo removes the background image plate, installs an animation, and changes the
foreground or source image plate, we need to add Java programming logic into the imageButtonOne
event handler structure next, which restores these settings in case the user has clicked on the
second (or third) ImageButton UI element.


The original AnimationDrawable would be setup by using the following code, which is shown in
Figure 10-27:


animImageView.setBackgroundResource(R.drawable.imageviewwhitering);
animImageView.setImageResource(R.drawable.anim_milkyway);
animImageView.setAnimation(null);

Free download pdf