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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:00:24+00:00 2026-05-23T12:00:24+00:00

With the default selector, long-pressing a list item causes its background to transition between

  • 0

With the default selector, long-pressing a list item causes its background to transition between two colors.

Replacing the selector with the one below removes the effect. According to this question, I need an animation to reproduce it. How would I go about doing that in xml?

<?xml version="1.0" encoding="utf-8"?>
<selector
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_pressed="true">
        <shape>
            <solid
                android:color="@color/state_pressed" />
        </shape>
    </item>
    <item
        android:state_focused="true">
        <shape>
            <solid
                android:color="@color/state_focused" />
        </shape>
    </item>
    <item>
        <shape>
            <solid
                android:color="@color/state_idle_grey" />
        </shape>
    </item>
</selector>
  • 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-23T12:00:24+00:00Added an answer on May 23, 2026 at 12:00 pm

    Here is the code from list_selector_background :

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
            <item android:state_window_focused="false" android:drawable="@android:color/transparent" />
            <!--
                    Even though these two point to the same resource, have two states so
                    the drawable will invalidate itself when coming out of pressed state.
            -->
            <item android:state_focused="true" android:state_enabled="false"
                    android:state_pressed="true"     android:drawable="@drawable/list_selector_background_disabled" />
            <item android:state_focused="true" android:state_enabled="false"
                    android:drawable="@drawable/list_selector_background_disabled" />
            <item android:state_focused="true" android:state_pressed="true"
                    android:drawable="@drawable/list_selector_background_transition" />
            <item android:state_focused="false" android:state_pressed="true"
                    android:drawable="@drawable/list_selector_background_transition" />
            <item android:state_focused="true"
                    android:drawable="@+drawable/list_selector_background_focus" />
    </selector>
    

    Found on the web.

    And it uses this transition for long press clicks :

    <transition xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:drawable="@drawable/list_selector_background_pressed"  />
        <item android:drawable="@drawable/list_selector_background_longpress"  />
    </transition>
    

    Found on the web too .

    There is no animation for that. And remember to keep you states in the same order, or at least think about it if you swap them, order is important.

    Personnally, I like when things behave in a standard way, so I would just let the standard list selector.

    Regards,
    Stéphane

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

Sidebar

Related Questions

On the default ListViews if you long press on an item the background fades
By Default in the Listview ,focus will come on the list item. Instead of
Is it possible to apply a custom background to each Listview item via the
I want to change ImageView background (in my case gradient color) using selector state
hi am using following xml as my customlistview background when am click an item
I have this Selector defined: <selector xmlns:android=http://schemas.android.com/apk/res/android> <!-- PRESSED --> <item android:state_pressed=true android:drawable=@drawable/backarrow_blueshiny />
I am trying to select the sub-menu item from a Wordpress default sidebar menu,
Google Checkout API, automatic default language selector? How do I select the google checkout
I have some clickable views and I want to set the default available background
default is 49 how to edit to higher?

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.