如何填写屏,四个按钮与表布局? [英] How to fill screen with four buttons with the Table layout?

查看:130
本文介绍了如何填写屏,四个按钮与表布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent"
    android:id="@+id/relativeLayout1" android:layout_height="fill_parent">
    <TableLayout android:id="@+id/TableLayout01" android:stretchColumns="*"
        android:layout_height="wrap_content" android:layout_width="fill_parent"
        android:layout_centerInParent="true" >
        <TableRow android:id="@+id/TableRow01" android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <Button android:id="@+id/syncDownload" android:layout_margin="5dp" android:layout_weight="1"
                android:layout_height="fill_parent" android:layout_width="fill_parent"
                android:text="Download1" android:textColor="#EDFF99"
                android:textStyle="bold" android:background="@drawable/custom_button" />
            <Button android:id="@+id/branchesButton" android:layout_weight="1"
                android:layout_margin="5dp" android:layout_height="wrap_content"
                android:layout_width="fill_parent" android:text="Download2"
                android:textColor="#EDFF99" android:textStyle="bold"
                android:background="@drawable/custom_button" />
        </TableRow>
        <TableRow android:id="@+id/TableRow02" android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <Button android:id="@+id/attendanceButton" android:layout_weight="1"
                android:layout_margin="5dp" android:layout_height="wrap_content"
                android:layout_width="fill_parent" android:text="Upload1"
                android:textColor="#EDFF99" android:textStyle="bold"
                android:background="@drawable/custom_button" />
            <Button android:id="@+id/syncUpload" android:layout_margin="5dp" android:layout_weight="1"
                android:layout_height="wrap_content" android:layout_width="fill_parent"
                android:text="Upload2" android:textColor="#EDFF99" android:textStyle="bold"
                android:background="@drawable/custom_button" />
        </TableRow>
    </TableLayout>
</RelativeLayout>

而出局

如何伸展四个按钮来填满整个屏幕?

How can i stretch the four buttons to fill the entire screen?

推荐答案

您不需要 TableLayout 此:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <LinearLayout
        android:layout_height="0dp"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal">
        <Button
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:layout_weight="1"
            ... />
        <Button
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:layout_weight="1"
            ... />
    </LinearLayout>
    <LinearLayout
        android:layout_height="0dp"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal">
        <Button
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:layout_weight="1"
            ... />
        <Button
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:layout_weight="1"
            ... />
    </LinearLayout>
</LinearLayout>

这篇关于如何填写屏,四个按钮与表布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆