0

I'm quite new to android programming and I stumbled upon a problem with my layout.

At first, I had a Linearlayout with a textview, 2 buttons and a imageview scaled to fit the screen.

Now I wanted to put this under a scrollview, so the imageview could be scaled larger (to the width of the screen).

Without the scrollview everything just went fine, but with the scrollview, my imageview is not scaled anymore.

What am I doing wrong? I tried numerous solutions on StackOverflow but I can't get it to work with a ScrollView. Thanks in advance!

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/pageno" />

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/texta" />

    <Button
        android:id="@+id/button2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/textb" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:adjustViewBounds="true"
        android:scaleType="fitCenter"
        android:src="@drawable/page1" />

</LinearLayout>
</ScrollView>
Hardy
  • 2,576
  • 1
  • 23
  • 45
tinus9779
  • 1
  • 1
  • http://stackoverflow.com/questions/4677269/how-to-stretch-three-images-across-the-screen-preserving-aspect-ratio This answered my question, thanks for helping out! – tinus9779 Apr 07 '13 at 00:47

1 Answers1

0

Make LinearLayout/RelativeLayout as parent view. In that make a scroll view and set alignparentTop=true. This scrollView will contain a single layout in which all other views will be placed.

Neha Nathani
  • 544
  • 4
  • 10
  • Thanks for helping! I tried RelativeLayout as parent view, then ScrollView as child with layout_alignParentTop=true and a LinearLayout(which contains all text/button/imageviews) as a child from ScrollView. But still no change. Also I get the warning the ScrollView is useless. I must be doing something wrong! – tinus9779 Mar 25 '13 at 19:02