【问题标题】:ImageView in CardView not show radius on Android 4.3CardView 中的 ImageView 在 Android 4.3 上不显示半径
【发布时间】:2017-11-17 18:20:29
【问题描述】:

这是我的布局 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 显示。 为什么?

【问题讨论】:

  • 在 android 5.0 以下无法使用。你必须通过使用drawables来做到这一点。

标签: android android-imageview android-cardview


【解决方案1】:

Android 4.3 上 CardView 中的 ImageView 不显示半径

CardView 海拔仅适用于 android 5.0 及更高版本

CardView 使用 Lollipop 上的海拔属性作为阴影,并回退到旧平台上的自定义模拟阴影实现。

由于圆角剪裁成本高昂,在 Lollipop 之前的平台上,CardView 不会剪裁与圆角相交的子项。相反,它添加了填充以避免这样的交集

更多信息read here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-23
    • 2020-10-06
    • 2019-06-18
    • 2015-06-03
    • 2018-03-16
    相关资源
    最近更新 更多