It is also possible to have the third color (center). And different kinds of shapes.
For example in drawable/gradient.xml:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#000000"
android:centerColor="#5b5b5b"
android:endColor="#000000"
android:angle="0" />
</shape>
This gives you black - gray - black (left to right) which is my favorite dark background atm.
Remember to add gradient.xml as background in your layout xml:
android:background="@drawable/gradient"
It is also possible to rotate, with:
angle="0"
gives you a vertical line
and with
angle="90"
gives you a horizontal line
Possible angles are:
0, 90, 180, 270.
Also there are few different kind of shapes:
android:shape="rectangle"
Rounded shape:
android:shape="oval"
and problably a few more.
Hope it helps, cheers!