ImageView within ScrollView, Height problem


Last Updated:

  1. JoshKraker

    JoshKraker Member This Topic's Starter

    Joined:
    Dec 3, 2009
    Messages:
    21
    Likes Received:
    0
    I'm using the following layout XML

    Code (Text):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    3.     android:layout_width="fill_parent"
    4.     android:layout_height="fill_parent">
    5.     <LinearLayout android:layout_width="fill_parent"
    6.         android:layout_height="wrap_content"
    7.         android:orientation="vertical"
    8.         android:padding="10px">
    9.         <ImageView android:id="@+id/ivImage"
    10.             android:layout_width="fill_parent"
    11.             android:layout_height="wrap_content"
    12.             android:scaleType="fitCenter">
    13.         </ImageView>
    14.         <TextView android:id="@+id/tvDescription"
    15.             android:text="Description:"
    16.             android:layout_width="fill_parent"
    17.             android:layout_height="wrap_content"
    18.             android:layout_below="@id/ivImage">
    19.         </TextView>
    20.         <EditText android:id="@+id/etDescription"
    21.             android:layout_width="fill_parent"
    22.             android:layout_height="wrap_content"
    23.             android:layout_below="@id/tvDescription">
    24.         </EditText>
    25.         <Button android:id="@+id/btnSend"
    26.             android:layout_below="@id/etDescription"
    27.             android:layout_width="fill_parent"
    28.             android:layout_height="wrap_content"
    29.             android:layout_alignParentRight="true"
    30.             android:text="Send">
    31.         </Button>
    32.     </LinearLayout>
    33. </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?
     

    Advertisement
  2. JoshKraker

    JoshKraker Member This Topic's Starter

    Joined:
    Dec 3, 2009
    Messages:
    21
    Likes Received:
    0
    I still haven't found a solution for this. Can anyone offer and hints?
     
  3. jean_marc

    jean_marc New Member

    Joined:
    Oct 27, 2012
    Messages:
    1
    Likes Received:
    0
    In your ImageView parameters, you can replace :
    Code (Text):
    1.  
    2. android:scaleType="fitCenter"
    3.  
    by :
    Code (Text):
    1.  
    2. android:adjustViewBounds="true"
    3.  
    It should solve the problem. :)
     

Share This Page

Loading...