Setting gradient color of TextView creates problems with selection color

by ChisterNordvik » Mon, 03 Nov 2008 13:38:29 GMT

Sponsored Links

I have a ListView with lines of TextViews (standings table for Premier

In the first column I want to have a gradient so I have modified my
code like this:

//Top team should have a nice green color
if(position == 0)
        toColor = Color.argb(255, 79, 191, 124);
        grad = new GradientDrawable(Orientation.TOP_BOTTOM,
                        new int[]{Color.GREEN, Color.BLACK, Color.GREEN});

But the selector is not happy with this because the gradient is at the
top of the selector. I tried painting the selector at the top with

But I couldn't get that to look any good. I also tried handling the
selectionChange property of the listview and setting background color
there but how can I clear the selection color when the listItem looses
selection? Do I have to loop through every item?

Are there any better ways of doing this?

Really appreciate any answers!