android-fragments 如何防止底部板材将角形状设置为正方形?

zkure5ic  于 2022-11-14  发布在  Android
关注(0)|答案(2)|浏览(120)

我把我的底片设计成这样

<style name="ShapeAppearanceOverlay.BottomSheet" parent="">
    <item name="cornerSize">30dp</item>
    <item name="cornerFamily">rounded</item>
</style>

它的工作很好我的底部工作表来了30dp的圆角半径,但如果我推幻灯片上我的底部工作表的角落变平了,我怎么能防止这种情况发生?
第一次

qlfbtfca

qlfbtfca1#

在底部工作表中使用此样式作为透明背景

<style name="BottomSheetMainStyle" parent="ThemeOverlay.MaterialComponents.Light.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/Widget.Test.BottomSheet.Modal</item>
    </style>

    <style name="Widget.Test.BottomSheet.Modal" parent="Widget.MaterialComponents.BottomSheet.Modal">
        <item name="backgroundTint">@android:color/transparent</item>
    </style>
uurity8g

uurity8g2#

我不知道,如果你已经解决了这个问题,但我在这里找到了一个解决方案,以防止尖角时,其扩大.她是链接:https://github.com/material-components/material-components-android/issues/1278#issuecomment-844979762
避免使用形状shapeAppearanceOverlay,并将其添加到用于bottomSheetDialogFragment的布局中,一个可绘制对象如下所示-〉

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
        android:topLeftRadius="24dp"
        android:topRightRadius="24dp" />
    <solid android:color="@color/light_white_dark_grey_02" />
</shape>

对于样式,请使用以下内容:

<style name="BottomSheetDialog" parent="@style/ThemeOverlay.MaterialComponents.BottomSheetDialog">
    <item name="bottomSheetStyle">@style/BottomSheet</item>
    <item name="android:colorBackground">@color/white</item>
</style>
<style name="BottomSheet" parent="Widget.MaterialComponents.BottomSheet.Modal">
    <item name="backgroundTint">@android:color/transparent</item>
</style>

这对我来说很有效,但我建议你看看我上面分享的链接;)

相关问题