Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 758315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:27:54+00:00 2026-05-14T15:27:54+00:00

I have a simple list with a listselector like so. <ListView android:id=@+id/list android:layout_width=fill_parent android:layout_height=fill_parent

  • 0

I have a simple list with a listselector like so.

<ListView android:id="@+id/list" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:layout_below="@+id/round"
    android:listSelector="#99000000" android:clickable="true" android:cacheColorHint="#00000000" android:background="#00000000">
</ListView>

As you can see android:listSelector=”#99000000″ but the “black alpha” color is applied to the entire list, not the selected item.


So this is what I have now but the entire list still turns black

::listview_background.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_enabled="false" android:state_focused="true"
        android:drawable="@drawable/list_normal" />
  <item android:state_pressed="true"
        android:drawable="@drawable/list_pressed" />
  <item android:state_focused="true"
        android:drawable="@drawable/list_active" />
</selector>

::colors.xml

<resources>
    <drawable name="list_normal">#96FFFFFF</drawable>
    <drawable name="list_active">#66000000</drawable>
    <drawable name="list_pressed">#CA000000</drawable>
</resources>

::the xml tag in my list

android:listSelector="@drawable/listview_background"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:27:55+00:00Added an answer on May 14, 2026 at 3:27 pm

    I had the same problem. I have a custom background image, and I don’t want to have to make variants of that background image because that would be tedious to represent all the different states.

    So I want to do the obvious thing, have a semi-transparent bar that is overlayed on top of the focused listitem and when the user taps the “enter” key or whatever, it flashes to the pressed overlay color which is more striking and somewhat more opaque.

    The solution was to stay away from any @color or @drawable that refers to a color inside listSelector. I created two 3×3 pixel .png files. Each saved with the gamma layer. In my case it’s two of the same color each mixed down in Gimp with a different transparency on the color layer. So when you select an item you get an overlay with 25% color, and when you press it you get a png with 50% color. I put them in my drawables as bg_list_item_pressed.png and bg_list_item_highlighted.png

    Then I set my list selector to:

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    
      <!-- Selected --> 
      <item 
        android:state_focused="true" 
        android:state_pressed="false" 
        android:drawable="@drawable/bg_list_item_highlighted" /> <!--  @drawable/tab_focus -->
    
      <!-- Pressed -->
      <item 
        android:state_pressed="true" 
        android:drawable="@drawable/bg_list_item_pressed" /> <!--  @drawable/tab_press -->
    
    </selector> 
    

    Then I added my listSelector attributes to my ListView in my layout xml:

    android:listSelector="@drawable/list_selector"
    android:drawSelectorOnTop="true"
    

    Now it works exactly how I want it to work. Including using the D-pad to select a row, and click it with enter. Getting the highlighting and subsequent pressing colors exactly how they should be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple list with a search. <ul data-role=listview data-inset=false data-filter=true data-iconpos=right> My
I have a simple list like this: <ul id=cyclelist> <li>Item 1</li> <li>Item 2</li> <li>Item
In my Android application, I have a simple list view with adapter. There's a
I have a simple List<string> and I'd like it to be displayed in a
I have a simple list like this: <ul id=large_box_custom_list> <li id=8 class=large_box>Item 1</li> <li
So I have a simple list thats set out like below <ul class='my-videos'> <li>
I have a simple list view listing results title in android. Upon click of
I have a simple list, which I managed to get in a line and
I have a simple list: mylist = [foo, bar, baz] and a QtTableWidget with
I have a simple list view with some check boxes in an alert dialog.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.