Monday, 16 February 2015

Crop Image View

CropImageView

An ImageView that supports different kind of cropping rather than the only Android is currently supporting: centerCrop
Using this library, you can crop your desired image by sides described below:
Crop options
Development idea borns at the point in [Kerad Games] we needed images cropped by somewhere no matter the image size.

Usage

Step 1

Gradle
dependencies {
   compile 'com.cesards.android:cropimageview:1.0.0'
}
Maven
<dependency>
   <groupId>com.cesards.android</groupId>
   <artifactId>cropimageview</artifactId>
   <version>1.0.0</version>
   <type>aar</type>
</dependency>

Step 2

Define in xml:
<com.cesards.cropimageview
   xmlns:custom="http://schemas.android.com/apk/res-auto"
   android:id="@+id/imageView1"
   android:src="@drawable/photo1"
   custom:crop="value" />
where value can take values
topLeft|centerLeft|bottomLeft|topRight|centerRight|bottomRight|centerTop|centerBottom
Or in code:
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);

No comments:

Post a Comment