In order to define a gradient that can be used in your app, define it an a resource file.

e.g. the resource file can be named as gradient.xml in the res/drawables directory of your project as:


  1. <?xml version="1.0" encoding="utf-8"?>
  2. <shape xmlns:android="">
  3.     <gradient
  4.         android:startColor="@color/White"
  5.         android:endColor="@color/Black"
  6.         android:angle="30"/>
  7. </shape>