Monday, September 5, 2011

Gradient dividers in Android

Many of Android’s screens use attractive dividers with gradients that fade from black to white to black.  Here’s how to create one of your own.


  

2. Create a view in the target layout and apply the gradient as the background.  The “black_white_gradient” in “@drawable/black_white_gradient” refers to the file name of the shape above.
<View android:id="@+id/divider"
    android:background="@drawable/black_white_gradient"
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:layout_below="@id/someOtherThing" />

0 comments: