Need Help! Contact me.Email me Thank You.

How do you define gradient color in Android?

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>
Subscribe to DeveloperFeedDid you like this article? Did it Help you Solve your Problem? You can get the all the latest articles published at DeveloperFeed in your email inbox by entering your email address below. Your address will only be used for mailing you the articles, and each one will include a link so you can unsubscribe at any time.