1
Hello, I’m beginner in android programming I am developing an app that loads images from the user’s gallery or camera. After selecting the image I use a Cropintent to cut the image. The problem is that I cannot resize the image to fit in Imageview, and the image loses considerably the quality.
Xml from Imageview:
<ImageView
android:id="@+id/ImageView"
android:layout_width="fill_parent"
android:layout_height="498dp"
android:layout_below="@+id/toolbar"
tools:layout_editor_absoluteX="11dp"
tools:layout_editor_absoluteY="61dp" />
This is the method I’m using to crop the image (The same method for camera and gallery images):
private void CropImage() {
try{
CropIntent = new Intent("com.android.camera.action.CROP");
CropIntent.setDataAndType(uri,"image/*");
CropIntent.putExtra("crop","true");
CropIntent.putExtra("outputX",400);
CropIntent.putExtra("outputY",400);
CropIntent.putExtra("aspectX",3);
CropIntent.putExtra("aspectY",4);
CropIntent.putExtra("scaleUpIfNeeded",true);
CropIntent.putExtra("return-data",true);
startActivityForResult(CropIntent,1);
}
catch (ActivityNotFoundException ex)
{
}
You can consider using Ibraries such as Glide or Picasso that do all the work of processing and loading images into imagesViews with the best possible quality in just 1 line of code.
– Márcio Oliveira
@Marcio, how do I do this? Just import these Libraries?
– H. Abreu
If you put wrap_content in width and height I think it would solve this friend dimension problem
– Paiva
I did this in Imageview. The component has adjusted to the edges but when the image loads, it never fits and with the very low quality.
– H. Abreu