Need Help! Contact me.Send Feedback Thank You.

How do you define gradient color in Android?

Answer
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:

res/drawables/gradient.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <shape xmlns:android="http://schemas.android.com/apk/res/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.