Android ConstraintLayout分组堆叠圆角ShapeableImageView
XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="match_parent"
android:background="@android:color/holo_green_light">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/image1"
android:layout_width="200dp"
android:layout_height="200dp"
android:rotation="-30"
android:scaleType="centerCrop"
android:src="@mipmap/pic1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/round_corner_style" />
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/image2"
android:layout_width="200dp"
android:layout_height="200dp"
android:rotation="-20"
android:scaleType="centerCrop"
android:src="@mipmap/pic2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/round_corner_style" />
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/image3"
android:layout_width="200dp"
android:layout_height="200dp"
android:rotation="-10"
android:scaleType="centerCrop"
android:src="@mipmap/pic3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/round_corner_style" />
<androidx.constraintlayout.widget.Group
android:id="@+id/group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
app:constraint_referenced_ids="image1,image2,image3" />
<com.google.android.material.imageview.ShapeableImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:rotation="0"
android:scaleType="centerCrop"
android:src="@mipmap/pic4"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/round_corner_style" />
</androidx.constraintlayout.widget.ConstraintLayout>
res/values/styles.xml:
XML
<style name="round_corner_style">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">15dp</item>
</style>
<style name="rounded_style">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>