簡體   English   中英

當BottomAppBar 從隱藏狀態返回時,BottomAppBar FabCradleMargin 變得更小,幾乎是平的

[英]BottomAppBar FabCradleMargin becoming less, almost flat, when BottomAppBar returns from being hidden

我的 FabCradleMargin 在我的應用程序中導航並在 hideonScroll 設置為 true 時向上/向下滾動時,在底部應用程序欄中變得更少,幾乎平坦。 當BottomAppBar 從屏幕上隱藏時,它會在浮動操作按鈕下返回調整大小。 一定是新的 Android Material Components 中的一個小故障。 有沒有其他人遇到過這個問題。 如果是這樣,你有什么建議來修復它。

前圖像

后圖像

<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()
}

因此,而不是隱藏的FloatingActionButton與visibility屬性,我用了hide()show()的方法FloatingActionButton

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM