• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

A Fragment that overlaps a control (e.g. button) on the underlying Activity

I have a Fragment that overlaps (entirely) a button control that resides on the underlying Activity in which the Fragment resides.

I know, that's weird, but that's how I want it to be.

The Fragment is initially Invisible when the app starts up. When a certain button is clicked on the underlying Activity that Fragment is made to be visible, using the show() function of the fragmentManager, e.g. :

fragmentManager.beginTransaction().show(theFragment).commit

That works just fine and theFragment does indeed become visible, totally obscuring another of the buttons on the underlying Activity.

So far that's exactly what I want it to do. [ Again, I know that's weird ]

I EXPECT that the underlying, now obscured, button will then be inaccessible to the user. He can't see it, the Fragment covers it up.

HOWEVER, if I actually do a click motion on the place where the button actually resides (hidden, underneath the Fragment), the button actually does get clicked, it's OnClickListener function does indeed get called.

That is NOT what I expected to happen. I figured that if a Fragment obscures some underlying control then that Fragment's UI takes precedence over anything that's beneath it.

Is there a way to indicate that the Fragment does indeed prohibit any underlying controls from being accessed since, after all, the user can't see them?

Yes, I could explicitly disable any and all underlying controls and re-enable them when the overlaying Fragment is again made invisible (hidden). But I'd really like it if there were a way to simply tell the Fragment to take precedence over any underlying controls.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones