导入依赖
implementation 'com.google.android.material:material:1.7.0'
布局文件添加
<com.google.android.material.imageview.ShapeableImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:shapeAppearanceOverlay="@style/circleImageViewRound" />
styles.xml中添加样式
<declare-styleable name="ShapeableImageView">
<attr name="shapeAppearanceOverlay" format="reference"/>
</declare-styleable>
<style name="circleImageViewRound">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>