CropImageView

介绍:

支持9个方向进行图片裁剪的ImageView。而android自带的ImageView 只支持centerCrop

运行效果:

使用说明:

添加依赖

Gradle

dependencies {
   compile 'com.cesards.android:cropimageview:1.0.1'
}

Maven

<dependency>
   <groupId>com.cesards.android</groupId>
   <artifactId>cropimageview</artifactId>
   <version>1.0.1</version>
   <type>aar</type>
</dependency>

xml中定义

<com.cesards.cropimageview
   xmlns:custom="http://schemas.android.com/apk/res-auto"
   android:id="@+id/imageView1"
   android:src="@drawable/photo1"
   custom:crop="value" />

其中alue可以的取值是topLeft|centerLeft|bottomLeft|topRight|centerRight|bottomRight|centerTop|centerBottom

或者用代码设置

CropImageView cropImageView = new CropImageView(CropActivity.this);
final Resources res = getResources();
cropImageView.setImageDrawable(res.getDrawable(images\[position\]));
final CropImageView.CropType cropType = imageCrops\[position\];
cropImageView.setCropType(cropType);
已下载
0