346 CHAPTER 9: Android Graphic Design: Making Your UI Designs Visual
- Right-click on this new /res/drawable folder and select the New ➤ Android
XML File menu sequence to get the dialog shown on the right-hand side of
Figure 9-31. Name the file ibstates1, which stands for image button states,
select the root element parenttag type, and then click the Finish
button. This will open up an emptyXML state definition file
in Eclipse. AXML state definition will allow you to implement a
selection set, much like the Java switch-case statement that you learned
about earlier in the book. This selector will allow the Android OS to select
amongst several different ImageButton drawable assets, based on the set of
four android:state parameters that will define your basic ImageButton states.
The child- tags inside of the parent
tag will implement
these android:state parameters, as well as reference the image assets using
the android:drawable parameter. This is shown in the ibstates.xml tab in
Eclipse in Figure 9-32, and uses the following XML mark-up format:
<?xml version="1.0" encoding="utf-8"
- tags inside of the parent
Figure 9-31. Right-click the /res folder and create a new folder (left) named drawable; create a new XML file (right)