-
-
Notifications
You must be signed in to change notification settings - Fork 302
Open
Labels
Description
The problem I am facing is that an image that's 4000x6000 won't fill the cropImageView container fully. While an image that's 1440x3088 will. All I want to do is when a user uploads an image, it always fills the entire cropImageView container. If that image is smaller than the container size, then it should zoom all the way up until it takes up the full container size. How do I achieve this?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.canhub.cropper.CropImageView
android:id="@+id/cropImageView"
android:layout_width="match_parent"
app:cropFixAspectRatio="false"
android:layout_height="300dp" />
</LinearLayout>
and here's the code of when I load the image into the cropImageView after I select an image from my camera roll:
private val cropActivityResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
val resultUri = result.data?.data
if (resultUri != null) {
// Set the cropped image to the CropImageView
binding.cropImageView.setImageUriAsync(resultUri)
// Apply the scale to the CropImageView
binding.cropImageView.scaleType = CropImageView.ScaleType.CENTER_CROP
}
}
}