Time for action - applying a gradient to an oval shape

The previous screenshot shows that while the oval looks okay, it's not going to be very visually appealing when surrounded by the gradient painted widgets which make up the default Android toolkit. In order to get the little oval to fit in nicely, it needs to look more like a ball, which requires a simple radial gradient to be applied.

  1. Create a new shape resource XML file in the res/drawable directory named ball.xml and open this file in an editor or IDE.
  2. Declare the root element of the file as an oval:
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    
  3. Instead of declaring a solid color as the fill, declare a gradient fill starting with a light grey and ...

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.