Sample code
- Add
CropImageView
into your activity
<!-- Image Cropper fill the remaining available height -->
<com.canhub.cropper.CropImageView
android:id="@+id/cropImageView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
- Set image to crop
cropImageView.setImageUriAsync(uri)
// or (prefer using uri for performance and better user experience)
cropImageView.setImageBitmap(bitmap)
- Get cropped image
// subscribe to async event using cropImageView.setOnCropImageCompleteListener(listener)
cropImageView.getCroppedImageAsync()
// or
val cropped: Bitmap = cropImageView.getCroppedImage()