Challenge: From Button to ImageButton

Perhaps the user interface would look even better if the next and previous buttons showed only icons, as in Figure 2.15.

Figure 2.15  Icon-only buttons

Icon-only buttons

To accomplish this challenge, these two widgets must become ImageButtons instead of regular Buttons.

ImageButton is a widget that inherits from ImageView. Button, on the other hand, inherits from TextView. Figure 2.16 shows their different inheritance hierarchies.

Figure 2.16  Inheritance diagram for ImageButton and Button

You can replace the text and drawable attributes on the Next button with a single ImageView ...

Get Android Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.