Image cropping in Android, there is a support in some devices by default for cropping image but its not reliable, so here is some code to get rid of this problem.
Step 1. Declare crop activity in your manifest like this :-
<activity android:name="com.soundcloud.android.crop.CropImageActivity" />
Step 2. Use Crop action like this :-
Crop.of(inputUri, outputUri).asSquare().start(activity)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent result) {
if (requestCode == Crop.REQUEST_CROP && resultCode == RESULT_OK) {
doSomethingWithCroppedImage(outputUri);
}
}
Step 3. Get the output Uri and use it on image view to show.
Step 4. Declare dependency in gradle.
compile 'com.soundcloud.android:android-crop:1.0.1@aar'
Helpful link :- https://github.com/jdamcd/android-crop
0 Comment(s)