Im trying to set my list view like the image im attached.Please anyone help me. Thanks in advance
Asked
Active
Viewed 97 times
0
-
[GradientDrawable](http://developer.android.com/reference/android/graphics/drawable/GradientDrawable.html) for background? (and transparent list items, cache color etc.) – snachmsm Feb 04 '15 at 08:49
-
1set transparent background to listview items, and set desired color or add image to background attribute of listview. – Apurva Feb 04 '15 at 08:50
-
It seem a job for a 9 patch (not a Gradient, since a Gradient doesn't sow **stripes**). The problem is that you have no control on how much the stripes grow in height. – Phantômaxx Feb 04 '15 at 08:54
-
http://stackoverflow.com/questions/1683185/how-do-i-create-a-listview-with-rounded-corners-in-android/1683195#1683195 – Aditya Vyas-Lakhan Feb 04 '15 at 08:56
3 Answers
2
Well I can only think of a workaround, where in your getView
(in the adapter) you set the background according to the position of the row. In other words, the bigger the pos
int the "darker" the background.

Alex.F
- 5,648
- 3
- 39
- 63
-
`the bigger the pos int the "lighter" (more yellowish) the background`, in this case. But, yes, it's a valid solution, +1. – Phantômaxx Feb 04 '15 at 08:56
1
I would set a gradient as a background for the list, like this:
<gradient
android:startColor="@color/orange"
android:centerColor="@color/middlecolor"
android:endColor="@color/yellow"
android:angle="0" />
and then set a drawable with a line or similar as a background of each cell.

MineConsulting SRL
- 2,340
- 2
- 17
- 32
1
Create a drawable for your gradient:
drawable/mybackground.xml
<item>
<shape android:shape="rectangle" >
<gradient
android:angle="270"
android:endColor="@color/red"
android:startColor="@color/orange"
android:type="linear" />
</shape>
</item>
Remember to declare "red" and "orange" colors:
values/color.xml
<color name="orange">#0000FF</color>
<color name="red">#FFA500</color>
Finally, set your drawable as ListView background:
<ListView
android:id="@+id/lvItems"
android:layout_width="match_parent"
android:layout_height="wrap_parent"
android:background="@drawable/mybackground" />

Juanjo Vega
- 1,410
- 1
- 12
- 20