如何programmically覆盖一个按钮?按钮、programmically

2023-09-04 10:49:03 作者:愛妳愛到心灰意冷▕

我想完成的是,在运行时,放置一个按钮在屏幕的中间,作为最上层的,覆盖下的所有内容。 (这不是很大的,所以它不会完全覆盖屏幕,只是无论发生什么事是它下面。)

What I would like to accomplish is to, at runtime, place a button in the middle of the screen, as the very top layer, overlaying anything below it. (It's not big, so it will not completely cover the screen, just whatever happens to be below it.)

我看着创建一个自定义对话框,但禁止所有其他用户输入。我希望所有的低于这个新的按钮正常行动,以响应用户的意见,但我只想补充(后来删除)按钮上方的一切。

I looked at creating a custom dialog, however that blocks all other user input. I want all of the views below this new button to act normally and respond to the user, but I just want to add (and later remove) the button above everything.

希望这是有道理的。我只是想知道什么可能是寻找到最好的办法?

Hopefully that makes sense. I'm just wondering what might be the best approach to look into?

感谢

推荐答案

使用的FrameLayout ,与按钮,因为它的第二个孩子。它设置为一去不复返了,你不希望它可见。

Use a FrameLayout, with the button as it's 2nd child. Set it to GONE when you don't want it visible.