A (175)

(Tuis.) #1

348 CHAPTER 9: Android Graphic Design: Making Your UI Designs Visual


Now all we have left to do to upgrade the graphic design elements in your SlidingPaneLayout
container that you created in the previous chapter is to use your Run As ➤ Android Application
menu sequence, to make sure that your ImageButton UI elements will change color when you click
on them, and add a reference to the NinePatch image asset that you created earlier in the chapter,
so that you can see that new Drawable asset type in action as well in your SlidingPaneLayout UI!


It’s important to note that not all of these interactive ImageButton states work in every AVD emulator,
so if you want to test the focused or hovered states, be sure to use an Android hardware device
that supports these to test your multi-state ImageButton XML markup. The reason I taught you
the most extensive and complete work process, all four states across all of the different resolution
densities that would be needed across any type or size device, is so that you know how to do this
in case you want your application to span every possible hardware device type and configuration.
If one of these states is not supported on a given hardware device, the Android OS will simply not
access that image asset which is attached to that android:state parameter. I’d play it safe, and
implement all of these ImageButton states in all of the resolution densities.


Adding a NinePatch to a SlidingPaneLayout


Finally, we need to implement the NinePatchDrawalbe asset that we created earlier in the chapter
in your SlidingPane Layout container, to show you how to use this type of Drawable asset with
your UI designs. If you’ve already run the app in the Nexus One AVD, you have seen that your
ImageButton UI elements look great, as you can see in Figure 9-34, on the left-hand side. You can
also see the NinePatchDrawable asset that we will be adding to the SlidingPaneLayout, as well as
the margin spacing that we will have to add to refine and perfect the UI design to work with the
NinePatchDrawable digital image asset.


Figure 9-33. Change your android:src parameters for each to reference the ibstates XML files

Free download pdf