0

How to scale ImageView to full screen of the device when the bitmap is 240*240 size. I have used following code.

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/layoutBGColor"
     android:clickable="true" >

<ImageView
    android:id="@+id/fullImage"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY" />

 ------
ImageView  iv = (ImageView)findViewById(R.id.fullImage);
iv..setImageBitmap(bitmap);

the bitmap is 240*240, bitmap is looks stratched. I have googled this and this but none of them worked. Please suggest me How can I set bitmap in full screen without stratching.

Community
  • 1
  • 1
maddy d
  • 1,530
  • 2
  • 12
  • 23
  • 1
    What do you want to happen? The image is smaller than your screen size, so either it will be stretched or there will be blank space around it. – Aleks G Oct 13 '14 at 16:06
  • impossible, if the bitmap dimensions are smaller than the screen its going to obviously need to stretch to fill it – tyczj Oct 13 '14 at 16:08
  • @AleksG what you said is correct. See If I add a zoom effect on it(bitmap) then it is not look stretched. I want some thing like that. I mean some how I can show it zoomed. – maddy d Oct 14 '14 at 05:24
  • How are you adding the zoom effect? You need to understand that there's no way to make a small image look good when stretched to large screen. If you want to display full screen images, then you have to get high res images. – Aleks G Oct 14 '14 at 07:05

1 Answers1

0

Obviously since the image size is smaller than the screen size, then definitely its going to stretch. If you are talking about maintaining the aspect ratio when you stretch the image then try the following piece of code.

<ImageView
    android:id="@+id/fullImage"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:adjustViewBounds="true"
    android:scaleType="fitCenter" />

The trick is to use android:adjustViewBounds.

Antrromet
  • 15,294
  • 10
  • 60
  • 75