有什么方法可以在不编辑 Java 文件的情况下通过 xml 文件隐藏/禁用 Android 中的 float 操作按钮?只想在应用程序中隐藏共享按钮,我尝试编辑相关的 xml 文件。试图设置不可见、消失等,但这些都不起作用。按钮还在。至少将按钮的大小减小到几乎看不见?我认为我们不能将 fab:fab_size="normal"
更改为其他值。所以那也行不通。那有什么办法吗??
最佳答案
Discussed已经在这个问题上, 主要原因是
If you set a set a
FloatingActionButton
to be anchored, you lose control of the visibility.
所以你必须先从 FloatingActionButton
中移除 layout_anchor
属性。
此时您必须在某处使用 java。不能只用 XML
来做 给出的技巧是
To wrap your FAB in a coordinator layout that is not the root of your entire layout, but as a sort of overlay to everything. From there you can manage the visibility of the coordinator layout initially so it's invisible, then make it visible when you call
fab.show()
.
关于android - 有什么方法可以通过 xml 隐藏 FAB( float 操作按钮)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36540951/