Alex
Alex

Reputation: 653

ImageView in CardView not show radius on Android 4.3

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+

radius

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

Now I run app on Android 4.3.

And here result: no_radius

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

Upvotes: 2

Views: 525

Answers (1)

Goku
Goku

Reputation: 9732

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

Upvotes: 1

Related Questions