Android材质组件底部应用程序栏切断
我已经尝试在应用程序栏底部实现material components,遵循这些指导原则,并对AndroidX+进行重构以更新我的应用程序主题。 到目前为止一切正常,但按钮在我的片段中被切断了。 然而,xml预览显示了这一点,看起来一切都很好: 以下是我的xml代码:Android材质组件底部应用程序栏切断,android,android-layout,material-design,floating-action-button,android-bottomappbar,Android,Android Layout,Material Design,Floating Action Button,Android Bottomappbar,我已经尝试在应用程序栏底部实现material components,遵循这些指导原则,并对AndroidX+进行重构以更新我的应用程序主题。 到目前为止一切正常,但按钮在我的片段中被切断了。 然而,xml预览显示了这一点,看起来一切都很好: 以下是我的xml代码: <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/androi
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- Other components and views -->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottombar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:elevation="2dp"
app:fabAlignmentMode="center"
app:fabCradleVerticalOffset="10dp"
app:fabCradleMargin="10dp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:adjustViewBounds="true"
app:layout_anchor="@id/bottombar"
app:layout_anchorGravity="top|center"
app:srcCompat="@drawable/marker" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
我甚至增加了fabCradleMargin
和fabCradleOffset
——否则按钮完全在底部,而不是像它应该的那样在半圆中浮动
有人找到线索了吗?非常感谢 所以我注意到它与底部应用程序栏的高度有关。如果我手动将其设置为
80dp
,则Fab将按预期显示
我试了一下,注意到这个手动高度设置只在片段中是必要的。我只是将底部的应用程序条放在一个片段中,以测试它。
因此,现在我以与我的MainActivity
指南中相同的方式实现它,然后设置一个函数showFab(布尔启用)
,然后可以根据需要在不同的片段中调用该函数
如果有人面临同样的问题,它就像一个符咒。我想这可能是因为它不应该只在一个片段中实现。问题不在于晶圆厂本身,而在于它前面的布局。请发布布局XML。