ImageView in CardView not show radius on Android 4.3

為{幸葍}努か 提交于 2019-12-24 02:22:34

问题


Here my layout 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>

Here result on Andrdoid 5.0+

As you can see the ImageView success show with radius. OK.

Now I run app on Android 4.3.

And here result:

As you can see the ImageView show without radius. Why?


回答1:


ImageView in CardView not show radius on Android 4.3

CardView elevation only work on android 5.0 and above

CardView uses elevation property on Lollipop for shadows and falls back to a custom emulated shadow implementation on older platforms.

Due to expensive nature of rounded corner clipping, on platforms before Lollipop, CardView does not clip its children that intersect with rounded corners. Instead, it adds padding to avoid such intersection

more information read here



来源:https://stackoverflow.com/questions/47347411/imageview-in-cardview-not-show-radius-on-android-4-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!