Android TableRow stretch vertically to fill screen

前端 未结 1 1516
情书的邮戳
情书的邮戳 2021-02-01 17:42

I\'m trying to create a phone dialer view, using a TableLayout to create the 12 buttons in a 3x4 grid. I would like the rows to stretch vertically to use up all available space

相关标签:
1条回答
  • 2021-02-01 18:07
    <?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"
    >
    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:stretchColumns="*"
        >
        <TableRow 
            android:layout_weight="1"
            android:gravity="center">
            <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
            <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
            <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
        </TableRow>
        <TableRow 
            android:layout_weight="1"
            android:gravity="center">
            <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
            <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
            <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
        </TableRow>
        <TableRow 
            android:layout_weight="1"
            android:gravity="center">
            <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
            <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
            <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
        </TableRow>
        <TableRow 
            android:layout_weight="1"
            android:gravity="center">
            <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
            <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
            <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
        </TableRow>
    </TableLayout>
    </LinearLayout>
    

    enter image description here

    0 讨论(0)
提交回复
热议问题