Android: Child elements sharing pressed state with their parent even when duplicateParentState specified

Viewed 19307

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.

3 Answers

Got same situation with SeekBar.

setting for SeekBar:

 android:clickable="true"
 android:focusable="true"

worked for me

Related