views:

27

answers:

3

When the user presses a ListView item (android:state_pressed="true") it flashes a shade of yellow (or you can press and hold).

What drawable is this? I've created my own selector because I want my own ListView item color , but I lose the pressed color.

There's an Android doc about skinning buttons that references #ffff0000, but this produces red.

Does anyone know what it is and how to reference it?

+1  A: 

A color is defined as #AARRGGBB where AA represents the alpha (transparency) value, RR the amount of red, GG the amount of green, and BB the amount of blue. Thus #ffff0000 is solid and all red. If you want orange, you want to add some green, i.e: #ffffA500. Google for RGB color values to see pages of colors with their rgb values.

Mayra
Yea, I've got this. I was just wondering the Android default. But thanks for your response
Andrew
+1  A: 

The thing your talking about is the Android OS built-in selector.

Make your own highlight with an xml-file in your drawable-folder like this:

<?xml version="1.0" encoding="utf-8"?>
  <selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; 
  <item android:state_pressed="true" android:color="#YOURCOLOR" /> 
  <item android:color="#FE896F" /> 
</selector>

Then in your XML-file there you have your ListView.

android:textColor="@drawable/highlight" //For text to appear like YOURCOLOR
//or if you wish the background
android:background="@drawable/highlight" //For the background to appear like YOURCOLOR

I hope this is it and tell me if this worked or not!

Julian Assange
Thanks for your response. I've already created a selector file like this. I used Romain Guy's trick to maintain a scroll pad selector on list items I've set a background color for. What I'm looking for is Android's default state_pressed color.
Andrew
You can do an ugly hack like print the pressed item and then look up the RGB color, but of course, the default color is declared somewhere.The problem is how to find it
Julian Assange
It actually looks more like a gradient of some value
Andrew
I believe it to be list_selector_background_pressed, but I don't know how to reference it. I've tried @android:drawable/list_selector_background_pressed, but to no avail
Andrew
It's like a mystery; I would be very appreciated for me to know the solution for this. Otherwise; it can't be like it is unavailable for programmers to change this specific thing?
Julian Assange
A: 

I have used a color picker tool in a photo editing application to find the outer and inner colors of the gradient and made my own.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="#ffb300"
        android:centerColor="#ffc800"
        android:endColor="#ffb300"
        android:angle="270"/>
</shape>
Andrew