Gluon Mobile 5.0.0 - 新的 FAB 行为导致麻烦

Gluon Mobile 5.0.0 - New FAB behaviour causes trouble

在我们的应用中,我们使用了多个浮动操作按钮。在 Gluon 4.4.4 中,我们将它们添加为层,具有以下行为:

现在,使用 Gluon 5.0.0(FAB 作为对象)会发生以下情况:

这导致了很多麻烦和不必要的代码行。我们如何改进它或它打算如何使用? 我们可以想象为整个应用程序使用一个 FAB 并为每个视图交换它的内容 - 然而,这最终也会变得更加混乱,因为它必须声明 public 等

感谢任何帮助:-)

您正在寻找新的 FloatingActionButton#showOn(View) 方法。

此方法确保根据视图的显示自动显示和隐藏 FAB 属性,删除早期版本中实现相同功能所需的大部分锅炉代码。

来自 Javadocs:

Makes sure that the FAB is automatically shown when the supplied view is shown. The FAB also automatically hides when the view is hidden. This allows the developer to not worry about calling show() and hide() methods explicitly.