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 6932105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:39:50+00:00 2026-05-27T11:39:50+00:00

I’m currently using a drawable for all of my buttons, which gets a gradient

  • 0

I’m currently using a drawable for all of my buttons, which gets a gradient over it when you press the button. I achieve this effect by using the various pressed-states and a layer-list.

Now I’m trying to create the same effect with a ListView. I’m able to show a different picture as the background for an object in the list when I click it, but whenever I try to add a picture with a separate gradient it shows up with the default Android color when clicking an object in the ListView. But, it does show my custom gradient on this default color.

I know this sounds a bit vague, so I took some screenshots to show the effect:

Button with gradient overlay, works fine

enter image description here

ListView with a background per object, does not work when using that image plus a gradient overlay

enter image description here

The drawable I’m using as the background image for the ListView

enter image description here

What could be the reason for the gradient working on the button, but not on the ListView? Like I said, using a completely different image for the pressed state works fine, but using the background image plus a gradient doesn’t.

Code used for the ListView pressed states

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Active tab -->
    <item android:drawable="@drawable/list_gradient" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
    <!-- Inactive tab -->
    <item android:drawable="@drawable/button_listpage_77px" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
    <!-- Pressed tab -->
    <item android:drawable="@drawable/list_gradient" android:state_pressed="true"/>
    <item android:drawable="@drawable/button_listpage_77px" />

</selector>

list_gradient.xml

    </item>
    <item>
        <shape xmlns:android="http://schemas.android.com/apk/res/android">
            <gradient android:angle="90" android:startColor="#880f0f10" android:centerColor="#8858585a" android:endColor="#88a9a9a9"/>
        </shape>
    </item>
</layer-list>

After fiddling around for a few hours today, I still haven’t been able to fix my problem. I know I’m missing something but I can’t seem to figure out what. Does anyone have an idea?

  • 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-27T11:39:50+00:00Added an answer on May 27, 2026 at 11:39 am

    After going over everything again, and reading all similar questions here on SO again, I noticed that nowhere in my files I used ‘android:listSelector`.

    After setting the following in my ListView:

    android:listSelector="#00000000", my ListView behaved as I wanted to!

    I figured that the ListView would work the same as all buttons, but I was wrong. Learn from my mistake, it might save you a whole lot of time.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported

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.