Skip to content

Latest commit

 

History

History
27 lines (24 loc) · 859 Bytes

crop_view.md

File metadata and controls

27 lines (24 loc) · 859 Bytes

Using CropView

Sample code

  1. 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"/>
  1. Set image to crop
cropImageView.setImageUriAsync(uri)
// or (prefer using uri for performance and better user experience)
cropImageView.setImageBitmap(bitmap)
  1. Get cropped image
// subscribe to async event using cropImageView.setOnCropImageCompleteListener(listener)
cropImageView.getCroppedImageAsync()
// or
val cropped: Bitmap = cropImageView.getCroppedImage()