
上面都是用ShapeableImageView写出来的效果
直接上代码:
布局文件:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/image0"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginTop="20dp"
android:src="@mipmap/image"
app:layout_constraintEnd_toStartOf="@id/image1"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/image1"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginTop="20dp"
android:src="@mipmap/image"
app:layout_constraintEnd_toStartOf="@id/image2"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toEndOf="@id/image0"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/RoundedStyle1" />
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/image2"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginTop="20dp"
android:src="@mipmap/image"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toEndOf="@id/image1"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/RoundedStyle2" />
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/image3"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginTop="20dp"
android:padding="2dp"
android:src="@mipmap/image"
app:layout_constraintEnd_toStartOf="@id/image4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTo
定制气泡效果:ShapeableImageView的多样圆角与裁切应用

本文详细展示了如何使用ShapeableImageView在Android中实现自定义的气泡效果,包括圆形、切角和不同区域的混合圆角,以及带有边框的图片样式。通过XML布局和样式文件,展示了如何调整图片尺寸、圆角大小和形状特性。
最低0.47元/天 解锁文章
2074

被折叠的 条评论
为什么被折叠?



