A (175)

(Tuis.) #1
CHAPTER 9: Android Graphic Design: Making Your UI Designs Visual 345

through” this user-determined pixel selection and algorithmic processing pipeline. Because of all of
these different modes which need to be set correctly in digital imaging, digital video editing, and in
3D modeling and animation, professional users really need to stay “on their toes” and realize exactly
what they are doing with these software modes at all times during the content creation process.
Content development, as well as software development, might appear to be quite simple, but in
reality, they are actually a lot more difficult than they seem to be on the “surface!”


Now you have the image assets in place to be able to create the ImageButton XML definition files
needed to implement a multi-state ImageButton which will access these 60 different digital image
assets that you just created!


Creating Your ImageButton’s XML Structure


The standard work process to define your ImageButton state is to utilize an XML Drawable
definition file, which will be located in the /res/drawable folder. This file has a parent
tag and child tag which define each of your ImageButton states, using custom digital image
asset references. Once the XML definition is set up, Android OS will select the correct image asset to
utilize based on the hardware device resolution, and the ImageButton state that is needed (normal,
pressed, focused or hovered) at the time.


The order of your state definitions inside of the parent selection container is quite
important. This is because these states will be evaluated in the order that they are encountered in
the XML Drawable definition file. This is why the normal image asset is referenced last, because it
will be displayed after the android:state_hovered, android:state_pressed, and android:state_focused
states are evaluated.


Let’s get started by creating your /res/drawable folder to hold the NinePatchDrawable asset as
well as the multi-state XML definition assets, which will then reference the 60 image state assets
you just created for the 5 primary drawable-dpi resolution density folders. XML definitions and
NinePatchDrawable assets will always go into this /res/drawable folder.



  1. Right-click on the /res folder under the HelloUniverse project folder, and
    select the New ➤ Folder menu sequence, which will open the dialog shown
    on the left-hand side of Figure 9-31. Name the folder drawable, select the
    /res folder, and then click the Finish button to create the new /res/drawable
    folder to hold your XML definitions.

Free download pdf