tags:

views:

285

answers:

1

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

+1  A: 

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"&gt;
<gradient android:angle="90" android:startColor="#7c0000" android:endColor="#A71C1C"/>
</shape>

thats it.

Praveen Chandrasekaran
How does the angle property work?
Janusz
set the xml attributes in the documentation you mentioned. the very first one android:angle
Praveen Chandrasekaran
... The problem in the documentation is that it does not show what the attribute angle is doing. Your answer produces a shape but I still have no clue how the gradientDrawable works.
Janusz
it works to me properly. i have no idea about your problem. if i got any idea let u know.
Praveen Chandrasekaran
it works for me too but I would like to understand how it works... Some code snippets don't help me understand the problem
Janusz