jcw
jcw

Reputation: 5162

How to force a tableview to use all screen space?

I have a table view, with some empty buttons in it. When I run my app, all the buttons are crammed into the top. How do I force the table to take up the whole screen area?

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableRow
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <Button 
        android:id="@+id/button1"
        />
</TableRow>

My layout is actually quite large, so this is just a sample of it

Upvotes: 0

Views: 158

Answers (2)

s.krueger
s.krueger

Reputation: 1043

<TableLayout android:stretchColumns="*" ... >

Instead of the *, you can specify columns to be streched, e.g. "1" or "1,2,3"

Upvotes: 1

Tuna Karakasoglu
Tuna Karakasoglu

Reputation: 1267

As I understood from your question here is the answer:

you could give gravity to rows. Like:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="fill_width"
    android:layout_height="wrap_content"
    android:gravity = 1.0 >
    <Button
        android:id="@+id/button1"
        android:text="button" />
</TableRow>

<TableRow
    android:id="@+id/tableRow2"
    android:layout_width="fill_width"
    android:layout_height="wrap_content"
    android:gravity = 1.0 >
    <Button
        android:id="@+id/button1"
        android:text="button" />
</TableRow>

Upvotes: 1

Related Questions