Skip to content Skip to sidebar Skip to footer

How To Trigger Selectors From The Layout View?

The problem Suppose you have a view inside a layout view, and you wish that each touching event on the layout would affect the view's background selector. for example, when you tou

Solution 1:

Consider you have a spinner inside a linear layout. Make focusable property of view(here that is spinner) to false. And onClick of linear layout call performClick on view(spinner in this case).

EDIT:

In focus Change Listener of linear layout if it has focus, call requestFocus on view. You can follow same method to other states of view

Another method:

do not apply any selector to layout(linearlayout in this case) and add whatever selector you want to view(spinner in this case). For view add this parameter

android:duplicateParentState="true"

Post a Comment for "How To Trigger Selectors From The Layout View?"