Setting gradient color of TextView creates problems with selection color

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


Sponsored Links
 Hi!

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

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});
        col0.setBackgroundDrawable(grad);
}

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
lv.setDrawSelectorOnTop(true);

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!

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Add Dynamic Views on to Relative Layout

Hi,

I need an advice of a good practice for the following situation.

I have defined my Relative Layout in an XML file. What I'd like to do
is to obtain a reference from that file in Java code, perform some I/O
operations, and based on the data I get to add a few views on to the
layout eventually.

At the moment I get a NullPointerException from my Activity when I do
the following:

RelativeLayout layout = (RelativeLayout) findViewById(R.layout.l1);
setContent(layout);

Is that a wrong way of obtaining a reference of my Layout?

Thanks!

--~--~---------~--~----~------------~-------~--~----~

2. Best approach to fullscreen video?

Our app has a simple 3 second intro video that plays the first time
the app is launched. So far we've experienced two issues with this.

The first is that we seem to be limited to H263 video in a 3GP
container at "standard" resolutions (i.e. 352x288).  H264 video
doesn't play at all in a 3GP container.  Is there a published list of
supported video codec and container combinations?

The second is that we can't get the VideoView to fill the screen in
the case that the source video does not exactly match the device
screen.  We'd like to be able to programatically determine the optimum
video dimensions and have the video player scale appropriately.
Setting the VideoView to FILL_PARENT works fine until the video starts
playing, at which time the VideoView is resized to the video
dimensions.

Is there an equivalent to a setWidth and setHeight that will stick?

This is our simple layout:

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">

    <VideoView android:id="@+id/surface"
               android:layout_gravity="center"
android:layout_width="fill_parent" android:layout_height="fill_parent"
               android:minHeight="480">
    </VideoView>

</LinearLayout>

Tried with and without the minHeight and the results appear identical.

Help?  Thanks!

--~--~---------~--~----~------------~-------~--~----~

3. Green notification light for calendar notifications

4. dom level 3 parser?

5. WebView and setDownloadListener

6. java.util.prefs and Android emulator - Newbie Question

7. T-mobile G1 for testing purposes