【发布时间】:2019-12-13 17:31:29
【问题描述】:
当我在 api 28 上运行我的代码时,我在卡片视图的内边缘看不到这个白色边框。但在 api 19 我得到以下渲染:
我的愿望是让颜色完全填满卡片视图,它应该剪掉角落,这样我就可以保持所需的圆角效果。这是显示其不起作用的简单演示代码:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="300dp"
android:layout_height="170dp"
android:theme="@style/Theme.MaterialComponents.Light"
app:cardBackgroundColor="@android:color/white"
app:cardCornerRadius="8dp"
app:cardElevation="4dp"
app:rippleColor="@android:color/transparent"
app:strokeWidth="0dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_dark" />
</com.google.android.material.card.MaterialCardView>
注意:看看它在 api 28 上呈现时的样子,这正是我想要的:
更新:我调整了
使用 app:cardPreventCornerOverlap="false" ,但使其不四舍五入。当我在它周围设置边框时,它现在不包含在边框中。
有人可以建议吗:
【问题讨论】: