Time for action - styling the calculator buttons

The next thing we need to do is use a selector-list and the nine-patch images you've just created to style the calculator buttons. We'll also be defining the button styling in a resource file so that we don't have to specify all of the styling for each of the buttons. In order to replace the standard button with our image, we only need to replace its background with the one we create for the purpose.

  1. In the res/drawable directory, create a new XML file named button.xml and open it in an editor.
  2. Define the root element of the file as a fixed-size selector:
    <selector xmlns:android="http://schemas.android.com/apk/res/android" android:constantSize="true" android:variablePadding="false">
  3. Create the pressed ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.