当BottomAppBar从隐藏状态返回时,BottomAppBar FabCradleMargin变得较少,几乎是平的 [英] BottomAppBar FabCradleMargin becoming less, almost flat, when BottomAppBar returns from being hidden

查看:0
本文介绍了当BottomAppBar从隐藏状态返回时,BottomAppBar FabCradleMargin变得较少,几乎是平的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在应用程序中导航并向上/向下滚动时,当hideonScroll设置为True时,我的FabCradleMargin在我底部的应用程序栏中变得较少,几乎平坦。当BottomAppBar隐藏在屏幕上时,它会在浮动的操作按钮下返回Resizeed。一定是新的安卓材料组件出现了故障。有没有其他人遇到过这个问题。如果是这样,您对修复它有什么建议。

<com.google.android.material.bottomappbar.BottomAppBar
    android:id="@+id/bar"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_gravity="bottom"
    app:elevation="4dp"
    app:fabAlignmentMode="center"
    app:fabCradleRoundedCornerRadius="2dp"
    app:hideOnScroll="true"
    app:layout_scrollFlags="scroll|enterAlways"
    app:navigationIcon="@drawable/ic_action_list" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:backgroundTint="@color/blue500"
    app:fabSize="normal"
    app:layout_anchor="@+id/bar"
    app:tint="@color/white"
    app:layout_anchorGravity="right"
    app:srcCompat="@drawable/ic_select_camera" />

推荐答案

我也遇到了这个问题。在我的例子中,这取决于我试图隐藏BottomAppBarFloatingActionButton的方式。这是我第一次(Kotlin):

private fun showBottomNavigationBar(barVisibility: Boolean, fabVisibility: Boolean) {
    navView.visibility = if (barVisibility) BottomAppBar.VISIBLE else BottomAppBar.GONE
    fab.visibility = if (fabVisibility) FloatingActionButton.VISIBLE else FloatingActionButton.GONE
}

以下是修复它的方法:

private fun showBottomNavigationBar(barVisibility: Boolean, fabVisibility: Boolean) {
    navView.visibility = if (barVisibility) BottomAppBar.VISIBLE else BottomAppBar.GONE
    if (fabVisibility) fab.show() else fab.hide()
}

因此,我使用了FloatingActionButtonhide()show()方法,而不是隐藏具有可见性属性的FloatingActionButton

这篇关于当BottomAppBar从隐藏状态返回时,BottomAppBar FabCradleMargin变得较少,几乎是平的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆