1. Download our Official Android App: Forums for Android!

Apps ImageView within ScrollView, Height problem

Discussion in 'Android Development' started by JoshKraker, Dec 6, 2009.

  1. JoshKraker

    JoshKraker Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    21
    Joined:
    Dec 3, 2009

    Dec 3, 2009
    21
    0
    15
    Software Engineer, AmTrust Financial Services Inc.
    Bath, OH, USA
    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 Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    21
    Joined:
    Dec 3, 2009

    Dec 3, 2009
    21
    0
    15
    Software Engineer, AmTrust Financial Services Inc.
    Bath, OH, USA
    I still haven't found a solution for this. Can anyone offer and hints?
     
  3. jean_marc

    jean_marc Lurker
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Oct 27, 2012

    Oct 27, 2012
    1
    0
    5
    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...