我尝试使用https://github.com/captain-miao/OptionRoundCardview这个仓库,但由于它提供的只是带有尖角的圆角卡片,所以并没有起到帮助作用。
我尝试使用https://github.com/captain-miao/OptionRoundCardview这个仓库,但由于它提供的只是带有尖角的圆角卡片,所以并没有起到帮助作用。
MaterialCard
,它是标准的Material Components库中包含的组件。
在你的布局中使用:
<com.google.android.material.card.MaterialCardView
style="@style/MyCardView"
...>
在您的样式中使用新的 shapeAppearanceOverlay
属性来自定义形状(需要版本 1.1.0.)。
<style name="MyCardView" parent="@style/Widget.MaterialComponents.CardView">
<item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay_only_on_top</item>
</style>
类似于:
<style name="ShapeAppearanceOverlay.MaterialCardView.Cut" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSizeTopRight">4dp</item>
<item name="cornerSizeTopLeft">4dp</item>
<item name="cornerSizeBottomRight">16dp</item>
<item name="cornerSizeBottomLeft">4dp</item>
</style>