【问题标题】:How to prevent menu from moving on FAB hide?如何防止菜单在 FAB 隐藏上移动?
【发布时间】:2020-09-05 08:52:27
【问题描述】:

我有BottomAppBarFloatingActionButton。当我使用fab.hide() 时,菜单从右上角移到了左边。如何解决这个问题?

它的外观:

然后我点击:

【问题讨论】:

  • 除了打电话给fab.hide(); 试试fab.setVisibility(View.INVISIBLE);
  • @MohammedAlaa 如果更改可见性,FAB 下的空白空间仍然存在。

标签: android layout menu floating-action-button


【解决方案1】:

您可以像这样删除菜单属性并添加图标:

<com.google.android.material.bottomappbar.BottomAppBar
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:fabAlignmentMode="end">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:background="?selectableItemBackgroundBorderless"
        app:srcCompat="@drawable/ic_more" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="?selectableItemBackgroundBorderless"
        app:srcCompat="@drawable/ic_search" />

</com.google.android.material.bottomappbar.BottomAppBar>

删除菜单属性后,如果需要,您必须自己创建溢出菜单。

【讨论】:

    猜你喜欢
    • 2014-11-08
    • 2010-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-28
    • 2021-12-03
    相关资源
    最近更新 更多