CHAPTER 15: Developing for Android Wearable Devices 573
This 2MB file is six times bigger, but also supports six types of Android devices (smartwatches,
smartphones, tablets, iTV sets, eReaders, and game consoles). If you wanted to optimize this, you
could remove the launcher_ic files that Android generated for you and you could use PNG8 format
for the image assets rather than PNG32, although your edges would not be as smooth unless you
used a uniform (pre-multiplied anti-aliasing) background color behind your analog clock background
graphic. See Figure 15-25.
Next, let’s take advantage of the Neptune Pine’s rectangular screen area and add some other
planets in the corner areas of the UI design. This will enable users to tap on each of the four corners
to change the planet that’s featured inside of the clock. You will use the ImageView class to add
60 pixel (one-fourth of 240 pixels) planet icons in the four corners of the current UI design using
layout_gravity and layout_margin parameters. Since you don’t need multi-state buttons, you
will use ImageView instead of ImageButton, as it will take up less memory. Remember that the
ImageButton class is subclassed from the ImageView class, which will add unneeded (in this
implementation) code overhead. These are all things that you need to consider when thinking about
your Android app’s optimization: memory, APK size, CPU cycles used, battery power, screen sizes
supported, and so on.
Adding Interactivity to the EarthTime App
Let’s add some interactivity to this application by placing other planet icons in the corners of the
display that the user can tap to change the planet that is used in the center of their clock design.
I’ve created the necessary planet icon and clock background graphics, which you can copy from the
book repository into the /res/drawable-mdpi folder. Multi-select (hold down the Ctrl key) the PNG32
files named earthbutton, marsbutton, neptunebutton, jupiterbutton, neptunetime, jupitertime,
and marstime, and paste them into your /res/drawable-mdpi folder, as shown in Figure 15-26.
Figure 15-26. Copy jupitertime, marstime, neptunetime, and the four planet name button image assets to MDPI