3

我想实现与此视图类似的东西,底部导航,左上角和右上圆角半径以及 a 和锚定 FAB在此处输入图像描述

4

1 回答 1

1

您可以使用标准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());

在此处输入图像描述

只是关于 new 的注释RelativeCornerSize(0.5f):它在1.2.0-beta01. 之前new RelativeCornerSize(50)

于 2020-07-14T06:46:53.957 回答