Search code examples
androidandroid-layoutandroid-scrollview

Android ScrollView Doesn't wrap to its child?


I have a problem with my ScrollView. It has an ImageView inside it. The imageView holds an image which is 480 * 3000 px. So It needs to be in a ScrollView so the user will have the ability to scroll down.

The problem is: when I test the application, the ScrollView does not wrap to the image hight. There is a black space under the image which is strange for me.

This is my XML code. I look forward for your opinion

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <ScrollView
    android:id="@+id/scroll_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scrollbars="vertical" >    
        <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/image"
        android:src="@drawable/image01"
        android:scaleType="fitStart" />     
    </ScrollView>
</RelativeLayout>

Update: This is how my image looks like with @ruhalde code. I can't take a screenshoot since it is big and you'll not see the whole picture so I draw it.

enter image description here


Solution

  • To those who might be interested:

    My problem was with the image I'm using, not how I organize my layouts. Thanks.