0

I am attempting to create a layout where in portrait mode an image fits the screen. However, in landscape mode, I would like only the width to be stretched to the screen size and the height (of the image) to be scrolled. The ratio of width to height of the image shouldn't change.

My problem is that I never seem to be able to get a scroll bar and my image is always squished vertically.

This is my xml file:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/meep" >
</ScrollView>

How can I change this code so that my image keeps its aspect ratio and a vertical scrollbar appears?

  • 1
    Whatever the approach, you probably want to use 2 different layouts: one for portrait, one for landscape. This is probably easier than making one layout function in both modes. See: http://stackoverflow.com/questions/4858026/android-alternate-layout-xml-for-landscape-mode – EJK Jan 09 '13 at 20:19
  • I am using 2 different layouts. My portrait shows the whole screen and works as expected but I want the image in my landscape layout to be scrollable. the xml file above is for the landscape mode. – user1964534 Jan 13 '13 at 01:53

0 Answers0