• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps ImageView within ScrollView, Height problem

I'm using the following layout XML

Code:
<?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="fill_parent">
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="10px">
        <ImageView android:id="@+id/ivImage"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scaleType="fitCenter">
        </ImageView>
        <TextView android:id="@+id/tvDescription" 
            android:text="Description:"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/ivImage">
        </TextView>
        <EditText android:id="@+id/etDescription"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/tvDescription">
        </EditText>
        <Button android:id="@+id/btnSend"
            android:layout_below="@id/etDescription"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="Send">
        </Button>
    </LinearLayout>
</ScrollView>
The problem is that the imageview takes up much more height then the image needs, adding a lot of blank space between the top of the screen and the following textview (tvDescription).

I'd like for the Image to scale to be the size of one screen (as if the only view in the layout was the ImageView) and the user would scroll down to see the other controls. Is this possible?
 
In your ImageView parameters, you can replace :
Code:
android:scaleType="fitCenter"
by :
Code:
android:adjustViewBounds="true"
It should solve the problem. :)
 
Back
Top Bottom