android:layout_weight is your friend here.This is a simple example with two
views each occupying half the screen:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<com.yunnanexplorer.android.gps.sats.SatelliteSkyView
    android:id="@+id/skyview"
    android:layout_width="fill_parent"
    android:layout_height="0px"
    android:layout_weight="2"
    />
<com.yunnanexplorer.android.gps.sats.SatelliteSignalView
        android:id="@+id/signalview"
    android:layout_width="fill_parent"
    android:layout_height="0px"
    android:layout_weight="1"
    />
</LinearLayout>

The weights add up and the screen is then divided according to the relative
weight a view claims.

HTH

Ludwig


2009/2/8 Xin Zhao <uszhao...@gmail.com>

> Hey guys,
>
> I am trying to define a view with the following requirements:
>
> 1. the view should occupy the entire screen, except the notification area
> (the top small bar)
> 2. The view should be even split into three parts, the top and bottom are
> two huge buttons, and the middle is a scrollable list. Note: no matter how
> many items in the list, it should only take 1/3 of view space.
>
> I created the following layout xml, but it has dimension hard coded, which
> is obviously undesired.
>
> What's the right way to do this?
>
> Thanks in advance!
> Xin
>
>
> My code (obviously not desired):
> -------------------------------------------------------
> <TableLayout
> android:id="@+id/widget146"
> android:layout_width="320px"
> android:layout_height="480px"
> android:orientation="vertical"
> xmlns:android="http://schemas.android.com/apk/res/android";
> >
> <TableRow
> android:id="@+id/widget147"
> android:layout_width="fill_parent"
> android:layout_height="116px"
> android:orientation="horizontal"
> >
>
>   <Button
>       android:id="@+id/favorite_card"
>       android:text="@string/favorite_card"
>       android:keepScreenOn="true"
>       android:layout_width="fill_parent"
>       android:layout_height="110px"
>       android:textSize="45px"/>
>
> </TableRow>
>
> <TableRow
> android:id="@+id/widget149"
> android:layout_width="fill_parent"
> android:layout_height="180px"
> android:orientation="horizontal"
> >
>
>   <ScrollView
>       android:id="@+id/ScrollView_CardSelector"
>       android:layout_width="fill_parent"
>       android:layout_height="180px"
>       android:scrollbars="none" >
>
>     <LinearLayout
>       xmlns:android="http://schemas.android.com/apk/res/android";
>       android:layout_width="fill_parent"
>       android:layout_height="180px">
>
>        <ListView android:id="@android:id/list"
>              android:typeface="sans"
>              android:textSize="20sp"
>              android:layout_width="fill_parent"
>              android:layout_height="180px"
>              android:animationCache="true"/>
>     </LinearLayout>
>   </ScrollView>
> </TableRow>
>
> <TableRow
> android:id="@+id/widget151"
> android:layout_width="fill_parent"
> android:layout_height="116px"
> android:orientation="horizontal"
> >
>   <Button
>       android:id="@+id/direct_call"
>       android:text="@string/direct_call"
>       android:keepScreenOn="true"
>       android:layout_width="fill_parent"
>       android:layout_height="110px"
>       android:textSize="45px"/>
>
> </TableRow>
>
> </TableLayout>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to