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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:28:01+00:00 2026-05-25T02:28:01+00:00

I have a SlidingDrawer element which contains a RelativeLayout element which contains some Button

  • 0

I have a SlidingDrawer element which contains a RelativeLayout element which contains some Button child elements:

<SlidingDrawer>
  <RelativeLayout>
    <LinearLayout>
      <Button android:background="@drawable/foo.xml" android:duplicateParentState="false">
      <Button android:background="@drawable/bar.xml" android:duplicateParentState="false">
    </LinearLayout>
  </RelativeLayout>
</SlidingDrawer>

foo.xml and bar.xml have selectors which apply different images depending on the state:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_focused="true" android:drawable="@drawable/foo_selected" />
  <item android:state_pressed="true" android:drawable="@drawable/foo_selected" />
  <item android:state_enabled="false" android:drawable="@drawable/foo_disabled" />
  <item android:drawable="@drawable/foo_normal" /> 
</selector>

The problem I am seeing is that when I click on the sliding drawer handle, the pressed state gets triggered for the buttons and they look pressed too, even though I’ve specified duplicateParentState to false.

  • 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-25T02:28:02+00:00Added an answer on May 25, 2026 at 2:28 am

    Override the LinearLayout class with a subclass. In that subclass override the setPressed method and do nothing like so:

    public class UnpressableLinearLayout extends LinearLayout
    {
        @Override
        public void setPressed(boolean pressed)
        {
            // Do nothing here. Specifically, do not propagate this message along
            // to our children so they do not incorrectly display a pressed state
            // just because one of their ancestors got pressed.
        }
    }
    

    Replace LinearLayout with an instance of UnpressableLinearLayout.

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

Sidebar

Related Questions

I have a slidingDrawer in my application that contains links which should be accessed
Consider the SlidingDrawer in Android. All samples I've seen have a large button as
In my application, I have to use SlidingDrawer on button click but my button
This is the scenario: I have a button B, and a slidingdrawer that when
I am developing an android application in which I have to make a layout.I
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I am trying to use a SlidingDrawer which has a bottom to top structure..
Hey! I have a SlidingDrawer in my application. When it opens, I want everything
Have created a ATL COM project through which I am inserting Menu Items to
I'm trying to create a SlidingDrawer with LinearLayout content over a FrameLayout. At first

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.