CHAPTER 10: Android Animation: Making Your UI Designs Move 363
Add a closing tag above the closing
Figure 10-4, and add an
parameters set to wrap_content and the required android:contentDescription set to a galaxyone
string constant.
Reference the anim_milkyway XML file you created using the android:src parameter for a source
foreground image plate for the ImageView, and use the imageviewwhitering PNG8 file using
the android:background parameter in the background plate. If you use your Run As ➤ Android
Application menu sequence now, you will notice that the animation overlays the top of the galaxy
info screen, so use an android:layout_below relative layout parameter to reference an ID that you
added to the first
to install this animation underneath your existing design. The
like this:
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/anim_milkyway" android:background="@drawable/imageviewwhitering"
android:layout_below="@+id/llh" android:contentDescription="@string/galaxyone" />
Now if you use the Run As ➤ Android Application menu sequence, you will see the results on the
left side of Figure 10-5. As you can see, the Android OS is scaling the foreground image resource
to match the size of your background image resource, even though we have provided assets with
different pixel dimensions. I made sure (using imaging software external to Android) that these would
match up perfectly, to the pixel, and Android is not “respecting” the pixel dimensions for my digital
imaging assets. I am going to show you how to get around this problem next, so you can achieve
the result shown in the other two panes (middle and right) in Figure 10-5.
Figure 10-5. Test markup (left), add adjustViewBounds parameter (middle), and add a padding parameter (right)