A (175)

(Tuis.) #1

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


Figure 10-37. Test the hybrid animation in Galaxy Nexus AVD (left) and add in the .setText( ) method calls (right)


If you want to learn more about PorterDuff blending, how to accomplish this using the Android
Canvas, Paint, and Bitmap classes is covered in my more advanced Pro Android Graphics
(Apress, 2013).


You could alternatively use GIMP 2.8 and its advanced color selection tools to remove the black parts
of these animation frames(images), replace them with alpha channel transparency, and save them as
PNG32 instead, which you learned how to do earlier in the book in Chapter 3 and Chapter 9. Time for
a little practice!


Next, we will take a quick look at how to use the .setText( ) method, inside of your ImageButton
event handling structure to put different statistics on your galaxy info screen for the two other galaxy
information screens using the TextView UI elements.


Completing the Galaxy UI Design: Using .setText()


You have already used this .setText( ) method in Chapter 6, to transfer data out of your Galaxy object
into your TextView UI widgets, and you can also use it in your programming logic here, to set the text
for your user interface elements. We will do this here, to reinforce how this is done. As you can see
in Figure 10-38, all you need to do is to call this .setText( ) method off of the TextView object names
declared at the top of your Activity and instantiated in your createUiTextViews( ) method, and pass
over your new (made up) galaxy information inside of the quotation marks as text (String) data. You
can copy the code from your transferDataValues( ) method into your imageButtonTwo onClick( )
handler if you want to speed up your code development work process.

Free download pdf