tags:

views:

24

answers:

1

I have a compound UI component built up from a ViewGroup containing a number of TextView, ImageView etc. components. Many of these have StateListDrawables as their images/backgrounds. Is there any way of making them select from this drawable based on the state of the parent ViewGroup rather than the component itself? Ideally I want to be able to change the visual state of all children of the ViewGroup (text colour, image etc) based on the state of the ViewGroup, preferably without having to hook up complex logical code. This seems like a fairly common sort of requirement, so I was hoping it would be straightforward in Android - am I going to be disappointed? :)

+1  A: 

No disappointment, just set android:duplicateParentState="true" in the layout file to enable what you want. You have to do that for each child View you want to have this functionality enabled on.

Qberticus
Can't believe I missed that one while searching through the Javadoc... Thanks.
Adrian