Android Image Cropper Library Image is not getting Match Parent in width and Height

223 Views Asked by At

In my new create Project i add image cropper library and it is not being match parent, i have tried all, below i am sharing my code and sdk versions.

 implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'

here is my main class where I am using this library as

class MainActivity : AppCompatActivity() {

private  val cropActivityResultContract  =  object  :
ActivityResultContract<Any? , Uri?>(){
    override fun createIntent(context: Context, input: Any?): Intent {
        return  CropImage.activity()
            .getIntent(this@MainActivity)
    }

    override fun parseResult(resultCode: Int, intent: Intent?): Uri? {
       return CropImage.getActivityResult(intent)?. uri
    }

}
private lateinit var cropActivityResultLauncher : ActivityResultLauncher<Any?>
private lateinit var chooseImage : Button
private lateinit var imageView: ImageView

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    chooseImage = findViewById(R.id.imgSelectImage)
    imageView = findViewById(R.id.image)

    cropActivityResultLauncher  = registerForActivityResult(cropActivityResultContract) {

        it?.let {
            imageView.setImageURI(it)
        }
    }

    chooseImage.setOnClickListener(View.OnClickListener {

        cropActivityResultLauncher.launch(null)
    })
}}

below is my XML File here I am getting cropped image its working fine after crop :

<androidx.appcompat.widget.AppCompatImageView
    android:scaleType="fitXY"
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

<androidx.appcompat.widget.AppCompatButton
    android:id="@+id/imgSelectImage"
    android:layout_below="@+id/image"
    android:text="Choose Image"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

I am Attaching my screenshot of device please check this as well

Screen shot of Image

Image is not fill in view background,please check image below. please suggest me thank you in advance, i would appreciate every suggestion.

1

There are 1 best solutions below

0
bugfreerammohan On

I changed Package Name of Project and Issue resolved