Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Android GradientDrawable

I try to use the GradientDrawable to set a gradient to some backgrounds and buttons. Sadly the documentation is not very detailed.

What are the main attributes to configure the gradient? I understand start and endcolor but some of the other attributes could need some explanation.

At the moment I used images as the background for the buttons but a drawable defined in XML would be much nicer.

I try to get a look like this (It is a very light gradient): alt text http://janusz.de/~janusz/RedButton.png

like image 394
Janusz Avatar asked Apr 19 '10 09:04

Janusz


People also ask

What is Android GradientDrawable?

A Drawable with a color gradient for buttons, backgrounds, etc. It can be defined in an XML file with the <shape> element.

What is gradients in android?

Designers are trying out different styles and combinations which go best with the Android App. One of the key components of Android being used these days is called GradientDrawable. A GradientDrawable is drawable with a color gradient for buttons, backgrounds, etc.


1 Answers

use this xml as background to the imageview.

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:angle="90" android:startColor="#7c0000" android:endColor="#A71C1C"/> </shape> 

thats it.

like image 61
Praveen Avatar answered Oct 02 '22 20:10

Praveen