Search code examples
androidxmlimageviewfill-parent

Android Imageview distorted when viewing on landscape large devices


I am currently trying to show an image using imageview, this image just has the certain height but it should fill the entire width of the screen. On portrait mode it and landscape mode on a mobile phone(Samsung galaxy note 2) it shows just fine but when I tried it on a tablet(Samsung galaxy tab), the portrait mode still looks great But in landscape mode what happens is that the image looks distorted, the image covers the entire width but the height seems to be off.

I did check it on the graphical layout but it looks ok.

this is my imageView:

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:adjustViewBounds="true"
    android:scaleType="centerCrop"
    android:src="@drawable/footersuperlong" />

Did I do something that makes it distorted?How can I make the image correctly display on the landscape view of a tablet?


Solution

  • The problem is the tab's width will be more compared to mobile phone. So the image get scaled up to match the width.

    You should use different image for different screens. Put different images in different drawable folder like hdpi,mdpi,xhdpi, If the images are stretchable use nine patch images.

    Define different layout for tablet sized screen.

    checkout multiscreen support and screen_sizes for more info