2

如何强制显示 BottomAppBar?我正在使用 viewpager,并且我的 BottomAppBar 具有 hideOnScroll 属性。我在 viewpager 中的第一个选项卡是可滚动的。一旦我在我的第一个片段上向下滚动,底部应用栏就会消失,然后当我转到视图寻呼机的第二个选项卡(不可滚动)时,底部应用栏不会重新出现。

<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">


<LinearLayout
    app:layout_dodgeInsetEdges="bottom"
    android:id="@+id/viewpagerRl"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/flContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

<com.google.android.material.bottomappbar.BottomAppBar
    android:id="@+id/bottomAppbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    app:backgroundTint="@color/colorPrimary"
    app:fabAlignmentMode="end"
    app:fabCradleRoundedCornerRadius="20dp"
    app:hideOnScroll="true"
    app:layout_scrollFlags="scroll|enterAlways"
    app:navigationIcon="@drawable/ic_hamburger"
    app:theme="@style/MerchantBottomAppBar" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_add_white"
    app:fab_size="normal"
    app:layout_anchor="@id/bottomAppbar"
    app:layout_anchorGravity="center" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
4

1 回答 1

0

以编程方式,您可以调用“performShow”。

请参阅https://developer.android.com/reference/com/google/android/material/bottomappbar/BottomAppBar#performshow上的文档

于 2020-04-02T15:37:08.670 回答