tags:

views:

134

answers:

1

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>
A: 

What you can do is change sizes depending on the screen programatically.

With this line you get the density of the screen:

scale = getResources().getDisplayMetrics().density;

and this this you get the size:

windowManager = getWindowManager(); display = windowManager.getDefaultDisplay(); screenWidth = display.getWidth(); screenHeight = display.getHeight();

and with this you can get is its on portarit or landscape:

Configuration conf = context.getResources().getConfiguration();

With all this info, you can modify the screen as you like.

Sometimes is necesary to do some calculations because not only density is different but size is different (like nexus one and droid)

Hope this helps.

Daniel

Daniel Benedykt
What do you mean by "you can modify the screen as you like" ?
rantravee
I meant that you can set 'fixed' sizes to the Views depending on the screen size, screen resolution and position. So on your case you can put a transparent image before the last button, and change the size of the transparent image depending on the situation. Let me know if you need more info.
Daniel Benedykt
Well , it probably would work, but this is the kind of fix I would rather avoid .
rantravee