views:

45

answers:

1

I've been toying around with a lot of different layout structures and can't seem to find the best one for my solution.

Essentially I need 3 rows that each take up 33% (height) of the device (in landscape mode). I thought would be perfect, but I can't seem to find a way to specify the height of a . It's possible I've overlooked a property somewhere, but I can't find it in the docs. I also thought of as an option but after playing around with that for a bit, I'm not sure that's the best solution either.

Can accomplish what I need? I will have other layouts specified within my rows (RelativeLayout primarily), but I just need the core structure to be 3 rows of 33% height each.

EDIT - Added Code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rellay"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/table_background">
    <LinearLayout
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <Button
            android:id="@+id/connect"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Connect To Server" />
    </LinearLayout>
    <LinearLayout
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TextView 
            android:id="@+id/label"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:scrollbars="vertical"
            android:maxLines="6"
            android:textColor="#FFFFFF" />
    </LinearLayout>
    <LinearLayout
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:stretchColumns="1">
            <TableRow>
                <RelativeLayout
                    android:id="@+id/cardssection"
                    android:layout_column="1" />
                <Button
                    android:id="@+id/submitcards"
                    android:gravity="right"
                    android:maxWidth="10px"
                    android:text="Submit Cards"
                    android:layout_below="@id/label" />
            </TableRow>
        </TableLayout>
    </LinearLayout>     
</LinearLayout>
+1  A: 

Take a look here http://stackoverflow.com/questions/3424904/how-to-split-the-screen-with-two-equal-linearlayouts/3425101#3425101. You just need add one more row to the solution. Note android:orientation="vertical" at the top-level LinearLayout.

Konstantin Burov
This is correct. Adding a layout_weight of 1 to your 3 inner LinearLayouts will space them out into 3rds on the screen. Use the solution posted in Burov's link and add a 3rd LinearLayout to the interior. Fyi, there's a syntax error (missing double quote) on one of the lines; and the attributes aren't properly named.
Andrew
Thx, I've fixed the errors.
Konstantin Burov
I tried what you suggested and it's not working. I've edited my OP to include how my layout is structured. I also tried changing the layout_weights to 1, 2, and 3 thinking that could be the problem, but it still doesn't work. I don't see anything other than the button in the first linearlayout.
Kyle
add android:orientation="vertical" to the top-level LinearLayout.
Konstantin Burov
ahh got it. Thanks much.
Kyle