Android 如何防止菜单在晶圆厂隐藏时移动?

Android 如何防止菜单在晶圆厂隐藏时移动?,android,layout,menu,floating-action-button,Android,Layout,Menu,Floating Action Button,我有BottomAppBar和FloatingActionButton。当我使用fab.hide()时,菜单从右到左移动。如何解决这个问题 它看起来怎么样: 然后我点击: 您可以删除菜单属性并添加如下图标: <com.google.android.material.bottomappbar.BottomAppBar android:layout_width="match_parent" android:layout_height="wrap_

我有
BottomAppBar
FloatingActionButton
。当我使用
fab.hide()时,
菜单从右到左移动。如何解决这个问题

它看起来怎么样:

然后我点击:


您可以删除菜单属性并添加如下图标:

<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>


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

除了调用
fab.hide()改为尝试
fab.setVisibility(View.INVISIBLE)@MohammedAlaa如果更改可见性,则FAB下仍保留空白。