Roman
Roman

Reputation: 4513

Using ScrollView for scrolling an ImageView

I'm trying to create a layout which consists of one long image which should be scrolled vertically only.

I.e. - it should stretch to take the whole screen width and stretch for the full height.

My layout does this, but it creates strange gaps before and after the image. Each gap takes about 2/3 of the screen and can be scrolled down.

How can I remove the gaps so that only the ImageView appears on the screen?

My activity XML is like this:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginTop="0dp" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="0dp"
        tools:context=".HelpActivity" >

        <ImageView
            android:id="@+id/imageHelp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="0dp"
            android:src="@drawable/tutorial_with_text" />
    </LinearLayout>

</ScrollView>

Upvotes: 1

Views: 2006

Answers (1)

Roman
Roman

Reputation: 4513

Found the solution: For future reference:

Use android:adjustViewBounds="true" on the ImageView

Upvotes: 7

Related Questions