CardView 中的 ImageView 在 Android 4.3 上不显示半径
ImageView in CardView not show radius on Android 4.3
这是我的布局 xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/catalog_item_card_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
card_view:cardCornerRadius="5dp"
card_view:cardUseCompatPadding="true">
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageViewPhoto"
android:layout_width="wrap_content"
android:layout_height="160dp"
android:src="@drawable/test_merchant_preview"
card_view:layout_constraintLeft_toLeftOf="parent"
card_view:layout_constraintRight_toRightOf="parent"
card_view:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
这里是 Andrdoid 5.0+ 的结果
如您所见,ImageView 成功显示了半径。好的。
现在我 运行 应用 Android 4.3.
结果如下:
如您所见,ImageView 显示没有半径。
为什么?
ImageView in CardView not show radius on Android 4.3
CardView
海拔仅适用于 android 5.0 及更高版本
CardView
在 Lollipop 上使用提升 属性 来实现阴影,并在旧平台上回退到自定义模拟阴影实现。
由于圆角裁剪的昂贵性质,在 Lollipop 之前的平台上,CardView
不会裁剪与圆角相交的子项。相反,它添加了填充以避免这种交叉
更多信息read here
这是我的布局 xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/catalog_item_card_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
card_view:cardCornerRadius="5dp"
card_view:cardUseCompatPadding="true">
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageViewPhoto"
android:layout_width="wrap_content"
android:layout_height="160dp"
android:src="@drawable/test_merchant_preview"
card_view:layout_constraintLeft_toLeftOf="parent"
card_view:layout_constraintRight_toRightOf="parent"
card_view:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
这里是 Andrdoid 5.0+ 的结果
如您所见,ImageView 成功显示了半径。好的。
现在我 运行 应用 Android 4.3.
结果如下:
如您所见,ImageView 显示没有半径。 为什么?
ImageView in CardView not show radius on Android 4.3
CardView
海拔仅适用于 android 5.0 及更高版本
CardView
在 Lollipop 上使用提升 属性 来实现阴影,并在旧平台上回退到自定义模拟阴影实现。
由于圆角裁剪的昂贵性质,在 Lollipop 之前的平台上,CardView
不会裁剪与圆角相交的子项。相反,它添加了填充以避免这种交叉
更多信息read here