对图片进行各种样式裁对图片进行各种样式裁剪:圆形、星形、心形、花瓣形等剪:圆形、星形、心形、花瓣形等--第三方开源--CustomShapeImageView

时间:2023-03-10 06:04:46
对图片进行各种样式裁对图片进行各种样式裁剪:圆形、星形、心形、花瓣形等剪:圆形、星形、心形、花瓣形等--第三方开源--CustomShapeImageView

对图片进行各种样式裁对图片进行各种样式裁剪:圆形、星形、心形、花瓣形等剪:圆形、星形、心形、花瓣形等--第三方开源--CustomShapeImageView

CustomShapeImageView在github上的项目主页是:https://github.com/MostafaGazar/CustomShapeImageView

如果仅仅是需要获取圆形、心形、花瓣形头像图片(具体看Demo),那么经过Android CustomShapeImageView简单XML设置就可以实现。

改不同的形状去demo中找不同的raw

对图片进行各种样式裁对图片进行各种样式裁剪:圆形、星形、心形、花瓣形等剪:圆形、星形、心形、花瓣形等--第三方开源--CustomShapeImageView

测试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>