I have a complex button which is made up of some layouts and Imagebuttons and then wrapped inside a Relativelayout for ease of use. The individual components work fine- I focus or click on one of the contained imagebuttons and it lights up as expected (drawable state list defines focus & click states).
Now I want this complex layout to behave as a unified button. I set
android:clickable="true" and android:focusable="true"
in the top-level layout. In all the sub-components I set
android:duplicateParentState="true" android:clickable="false" android:focusable="false".
With this I get the expected behavior for touch cases- I touch the layout anywhere and all the contained components light up. However, focus does not work. Rolling the trackball now completely ignores the complex button.
It seems that you’ve done everything right with
android:clicableandandroid:focusableflags. This logic should work. Try to explicitly declare the order of focus selection withandroid:nextFocusoptions.