View elevation with clipChildren not work

12 Views Asked by At

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clipChildren="false"
    android:clipToPadding="false"
    android:orientation="horizontal">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="#ffff00" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="#ff0000">

        <ImageView
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="@mipmap/img_plan_circle"
            android:elevation="2dp"
            android:translationZ="5dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toLeftOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageView
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="@mipmap/img_plan_circle"
            android:elevation="2dp"
            android:translationZ="2dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toRightOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </androidx.constraintlayout.widget.ConstraintLayout>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="#ff00ff" />
</LinearLayout>

above is my sample code

the first image is work perfectly but second one is cut

even though i set android:elevation="2dp" or android:translationZ="2dp"

Both are not working.

How to let second one clipChildren currently?

0

There are 0 best solutions below