Android Overlapping Views and OnClick

I have a frame layout with some layout as the first element and another layout as the second (and therefore above the first). The top layout is translucent, so you can see what is at the bottom of the bottom layout:

<FrameLayout> <BottomLayout android:onClick="BottomClicked"> <Button android:onClick="ButtonClicked"/> <TextView/> <TextView/> </BottomLayout> <TopLayout android:background="@color/semi-transparent" android:onClick="TopClicked"> </TopLayout> </FrameLayout> 

The bottom layout will change over time, with the addition / removal of views or the setting of visible / invisible / departed. I would like to be able to fire the onClick event for both the top layout and everything that can be below it.

For example, if the user clicks on the part of the top layout that is also above the button in the bottom layout, I would like to call onClick for both the top layout and the button in the bottom layout. At the moment, only onClick for the top layout is called

EDIT:

Edited question will be more general / less specific

+4
source share
1 answer

You can call the button click method by clicking the button, or you can use the nested insert that matches the size of your image to set the click area as a button: See here

EDIT: If you can use the onTouch event instead of the onClick event, you can return false from the onTouch methods so that they propagate through the stack.

+3
source

All Articles