gpt4 book ai didi

安卓 : Add rounded corners to BottomAppBar with circular anchored FAB

转载 作者:行者123 更新时间:2023-12-04 04:10:23 37 4
gpt4 key购买 nike

我想实现与此 View 类似的东西,底部导航具有左上角和右上角圆角半径以及锚定的 FAB enter image description here

最佳答案

您可以使用标准的 BottomAppBar:

   <com.google.android.material.bottomappbar.BottomAppBar
android:layout_margin="xxdp"
app:fabAlignmentMode="center"
app:fabCradleRoundedCornerRadius="2dp"
app:fabCradleVerticalOffset="8dp"
app:fabCradleMargin="8dp" />

然后更改ShapeAppearanceModel:

    BottomAppBar bottomAppBar = findViewById(R.id.bottomAppBar);
MaterialShapeDrawable bottomBarBackground = (MaterialShapeDrawable) bottomAppBar.getBackground();
bottomBarBackground.setShapeAppearanceModel(
bottomBarBackground.getShapeAppearanceModel()
.toBuilder()
.setAllCorners(new RoundedCornerTreatment()).setAllCornerSizes(new RelativeCornerSize(0.5f))
.build());

enter image description here

关于新的 RelativeCornerSize(0.5f) 的注意事项:它在 1.2.0-beta01 中发生了变化。在 new RelativeCornerSize(50)

之前

关于安卓 : Add rounded corners to BottomAppBar with circular anchored FAB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61837446/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com