ScrollView in android

Posted by rantravee on Stack Overflow See other posts from Stack Overflow or by rantravee
Published on 2010-06-09T18:11:17Z Indexed on 2010/06/09 18:12 UTC
Read the original article Hit count: 447

Filed under:

hi,

I' have a view that contains several textViews an ImageView and a Button . Because on small screen devices (or in landscape mode on big ones ) not all are visible I use a Scroll as the parent of the whole hierarchy to allow the user to view all the information. The things are suck that the button must be at the buttom of the view . However on big screen device , where it remains enough space at the buttom , the button is put immediatelly below the last textview,and seems to occupy all the remaining space (resulting in an unnactractive view) . Trying to use android:allignParentButtom ="true" not only that it has no effect but it puts the button at top of the screen . Has anyone any ideea how could I accomplish what I described ?

here's the xml

<?xml version="1.0" encoding="utf-8"?>
  <ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scroll_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true">


     <RelativeLayout
         android:id="@+id/gps_info_page1"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:layout_centerHorizontal="true">

       <TextView
            android:id="@+id/itsDateTimeValue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:text="@string/eStrUnknown">
       </TextView>

     <RelativeLayout
             android:id="@+id/directions"
             android:layout_centerHorizontal="true"
             android:layout_below="@+id/itsDateTimeValue"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content">

         <TextView
                android:id="@+id/itsDirectionValue"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="0"
                android:layout_marginRight="2dip"
                android:textSize="20sp">
        </TextView>
        <TextView
                android:id="@+id/itsOrientation"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20sp"
                android:layout_marginLeft="2dip"
                android:text="@string/eStrUnknown"
                android:layout_toRightOf="@+id/itsDirectionValue">
        </TextView>
    </RelativeLayout>



    <ImageView
        android:id="@+id/itsImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/compass"
        android:layout_below="@+id/directions"
        android:layout_centerHorizontal="true">
     </ImageView> 

    <RelativeLayout>
       ..."TextViews below the above image"
    </RelativeLayout> 

    <RelativeLayout>
      ..."TextViews below the above"         
    </RelativeLayout>

    <RelativeLayout>
     ..."TextViews below the above"  
    </RelativeLayout> 

    <RelativeLayout>
    ..."TextViews below the above"            
   </RelativeLayout>

   <RelativeLayout
    ..."TextViews below the above" 
  </RelativeLayout>


   <LinearLayout
      android:id="@+id/div"
      android:layout_width="fill_parent"
      android:layout_height="1dip"
      android:layout_below="@+id/sunset_layout"
      android:background="#F333">
   </LinearLayout>

   <Button  //adding here android:alignParentBottom="true" has described above behavior
     android:layout_marginBottom="3dip"
     android:layout_marginTop="20dip"
     android:id="@+id/done_button"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="@string/eStrDone"
     android:textSize="18sp"
     android:layout_below="@+id/div"
     android:layout_centerHorizontal="true">
    </Button> 


   </RelativeLayout>

</ScrollView>

© Stack Overflow or respective owner

Related posts about android