Making icons change with state

In Android, images have state; they can change how they look according to the widget that is using them. In fact, this is how a button works; it has a background image that changes state depending on whether it's pressed, released, enabled, disabled, focused, and so on. For us to show the user which of these categories they have actually selected, we need to provide them with a visual indication on the icon. This involves some editing:

  1. Start by making a copy of the ic_accommodation_black.xml file that was generated, and name this one ic_accommodation_white.xml. Use copy, and then paste the file into the same directory to have Android Studio bring up a Copy dialog.
Vector graphics in Android are XML files representing ...

Get Hands-On Android UI Development 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.