Set image size in full screen on Android

I have an Android app in which I take a picture using an Android camera. This image is taken in activity A and then sent to activity B , where it is being edited.

This is how I get my image in activity B :

 Bundle extras = getIntent().getExtras(); BitmapFactory.Options options=new BitmapFactory.Options(); options.inSampleSize = 5; byte[] imageData = extras.getByteArray("imageData"); Bitmap myImage = BitmapFactory.decodeByteArray(imageData , 0, imageData.length,options); Matrix mat=new Matrix(); mat.postRotate(90); bitmapResult = Bitmap.createBitmap(myImage, 0, 0, myImage.getWidth(), myImage.getHeight(), mat, true); ImageView imageView = (ImageView) findViewById(R.id.myPic); imageView.setImageBitmap(bitmapResult); 

As you can see, I rotate the bitmap , I get with 90:

 Matrix mat=new Matrix(); mat.postRotate(90); 

And here is my imageView in the XML file:

 <ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" android:id="@+id/myPic" /> 

The problem I am facing is that my picture is not in full screen ... it is almoust full screnn but not entirly.As you can see here:

enter image description here

If you could help me increase its size a bit, I would really appreciate it. thanks

EDIT: I want to increase the width of only my image. Sorry!!

+7
source share
3 answers

You may need to crop the image. Since the image is not at full height, the image width is proportionally reduced, so there are black bars on the sides.

To be more specific, images made using the phoneโ€™s camera are probably designed to fit the screen exactly, that is, the ratio of the width to the width of the image = the ratio of the width to the width of the screen. However, in your application, the image height is limited by the buttons at the top, therefore, in order to maintain the ratio of image width to width, the image width is reduced proportionally.

+4
source

You can use ImageView.ScaleType

 ImageView.ScaleType="CENTER_CROP" 
+5
source

Refer to setScaleType

You can use CENTER_CROP to get a full-screen image and maintain the aspect ratio of the image.

+4
source

All Articles