1. Are you ready for the Galaxy S20? Here is everything we know so far!

ImageView within ScrollView, Height problem

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

  1. JoshKraker

    JoshKraker Newbie
    Thread Starter

    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?
     



    1. Download the Forums for Android™ app!


      Download

       
  2. JoshKraker

    JoshKraker Newbie
    Thread Starter

    I still haven't found a solution for this. Can anyone offer and hints?
     
  3. jean_marc

    jean_marc Lurker

    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. :)
     
Loading...
Similar Threads - ImageView within ScrollView
  1. Sanjit Keksar
    Replies:
    4
    Views:
    781
  2. Thomas Thorton
    Replies:
    0
    Views:
    679
  3. DerekPixel
    Replies:
    5
    Views:
    450
  4. lister171254
    Replies:
    1
    Views:
    1,988
  5. DJR_Android
    Replies:
    2
    Views:
    1,168
  6. RATKEN
    Replies:
    0
    Views:
    1,498
  7. David Ramer
    Replies:
    0
    Views:
    488
  8. paulri
    Replies:
    3
    Views:
    2,076
  9. CitingGazelle
    Replies:
    1
    Views:
    686
  10. RioLeal
    Replies:
    0
    Views:
    525

Share This Page

Loading...