【问题标题】:How to Force Show BottomAppBar - Android如何强制显示 BottomAppBar - Android
【发布时间】:2019-05-17 10:45:00
【问题描述】:

如何强制显示 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>

【问题讨论】:

  • 显示BottomAppBar的代码
  • 更新了我的帖子
  • 表示你不想让你的 BottomAppBar 隐藏吧?
  • 我想手动显示我的底部应用栏。从我的第一个片段开始。底部的应用栏可以通过滚动隐藏。但是当我转移到另一个片段时(而底部的 appbar 是隐藏的)它不会显示回来,即使片段不可滚动

标签: android material-design androidx android-bottomappbar


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2015-07-03
    • 2013-04-24
    • 2018-07-08
    • 1970-01-01
    • 2018-12-29
    • 1970-01-01
    • 1970-01-01
    • 2020-12-28
    • 1970-01-01
    相关资源
    最近更新 更多