CustomShapeImageView在github上的项目主页是:https://github.com/MostafaGazar/CustomShapeImageView
如果仅仅是需要获取圆形、心形、花瓣形头像图片(具体看Demo),那么经过Android CustomShapeImageView简单XML设置就可以实现。
改不同的形状去demo中找不同的raw
测试xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.testcustomshapeimageview.MainActivity" > <com.meg7.widget.CustomShapeImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerCrop"
android:src="@drawable/test_girl"
app:shape="circle" /> <com.meg7.widget.CustomShapeImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="centerCrop"
android:src="@drawable/test_girl" /> <com.meg7.widget.RectangleImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerCrop"
android:src="@drawable/test_girl" /> <com.meg7.widget.SvgImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="centerCrop"
android:src="@drawable/test_girl"
app:svg_raw_resource="@raw/shape_star" /> </LinearLayout>