简介:A View for cropping images that is similar to Instagram's crop. Also an Activity for cropping is included.
更多:作者   提 Bug   

A View for cropping images that is similar to Instagram's crop. Also an Activity for cropping is included.

alt tag


Add the dependency:

dependencies {
    compile 'com.yashoid:instacropper:1.0.6'

How to use this library

Add InstaCropperView to your xml layout

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android=""

        app:backgroundColor="@android:color/white" />


InstaCropperView receives only Uri but any Uri is possible.


You can specify three size ratios for the crop. The narrowest allowed, the widest allowed and the ideal ratio. The View will adjust its size by the ideal ratio.

mInstaCropper.setRatios(defaultRatio, minimumRatio, maximumRatio);

The cropped image is returned in a callback. You can specify MeasureSpec to adjust the width and height of the returned Bitmap.

        View.MeasureSpec.makeMeasureSpec(1024, View.MeasureSpec.AT_MOST),
        View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
        new InstaCropperView.BitmapCallback() {

            public void onBitmapReady(Bitmap bitmap) {
                // Do something.


It is also possible to use the crop feature via an Intent call. There are various getIntent() methods defined on InstaCropperActivity. You will then receive the crop result in data.getData().

Intent intent = InstaCropperActivity.getIntent(context, srcUri, dstUri, maxWidth, outputQuality);
startActivityForResult(intent, REQUEST_CROP);

You can modify the crop Activity's apprearance by overriding the following resouce values:

<string name="instacropper_title">Crop</string> <!-- Title of toolbar -->
<string name="instacropper_crop">Crop</string> <!-- Title of crop action in toolbar -->

<color name="instacropper_cropper_background">@android:color/white</color> <!-- Background color of InstaCropperView in the activity -->
<color name="instacropper_crop_color">@android:color/black</color> <!-- Color of crop action in toolbar -->

<style name="InstaCropper" parent="android:style/Theme.DeviceDefault.Light"/> <!-- Style of crop Activity -->
Android 开发经验分享
C 轮融资近 30 亿元理财推荐
Android 开发经验分享
C 轮融资近 30 亿元理财推荐