Crop an image when selected from gallery in android

后端 未结 6 561
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 08:51

I want to crop an image in my application when it is selected from gallery. i.e if I launch the gallery and select an image the cropping window should come like when we sele

6条回答
  •  感情败类
    2020-12-02 09:18

    Nobody will tell you which extra is needed unless you try it:

       val intent = Intent(Intent.ACTION_PICK)
       intent.apply {
           type = "image/*"
           putExtra("crop", "true") // NOTE: should be string
           putExtra("outputX", 300) // This is needed, editor can't close without these two
           putExtra("outputY", 300) // This is needed
    
           putExtra("scale", true)
           putExtra("aspectX", 1)
           putExtra("aspectY", 1)
           putExtra("return-data", true)
       }
       startActivityForResult(intent, YOUR_INT_CODE)
    

提交回复
热议问题