Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android XML布局在中间没有完全对齐_Android_Xml - Fatal编程技术网

Android XML布局在中间没有完全对齐

Android XML布局在中间没有完全对齐,android,xml,Android,Xml,这是我的xml布局代码 <?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">

这是我的xml布局代码

    <?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">
    <TextView android:id="@+id/titleset"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Orb Runner"
    android:layout_gravity="center"
    android:gravity="center"
    android:layout_marginTop="20dp"
    android:textSize="45sp"
    android:textColor="#FF3366CC"/>

    <TableLayout android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:layout_marginTop="30dp"
    android:gravity="center"
    android:layout_gravity="center">

    <TableRow android:layout_gravity="center"
    android:gravity="center" android:layout_width="fill_parent">

    <TextView android:id="@+id/newgamebut"
    android:layout_marginRight="5dp"
    android:text="New Game"
    style="@style/Button" android:layout_height="fill_parent" android:layout_width="wrap_content"/>

    <TextView android:id="@+id/newgamebut"
    android:layout_marginLeft="5dp"
    android:text="High Score"
    android:layout_gravity="center"
    style="@style/Button" android:layout_height="fill_parent" android:layout_width="fill_parent"/>

    </TableRow>

    <TableRow android:layout_gravity="center"
    android:gravity="center" android:layout_width="fill_parent">

    <TextView android:id="@+id/newgamebut"
    android:layout_marginRight="5dp"
    android:text="Settings"
    style="@style/Button" android:layout_height="fill_parent" android:layout_width="wrap_content"/>

    <TextView android:id="@+id/newgamebut"
    android:layout_marginLeft="5dp"
    android:text="Instructions"
    android:layout_gravity="center"
    style="@style/Button" android:layout_height="fill_parent" android:layout_width="fill_parent"/>

    </TableRow>

    <TableRow android:layout_gravity="center"
    android:gravity="center" android:layout_width="fill_parent">

    <TextView android:id="@+id/newgamebut"
    android:layout_marginRight="5dp"
    android:text="About"
    style="@style/Button" android:layout_height="fill_parent" android:layout_width="wrap_content"/>

    <TextView android:id="@+id/newgamebut"
    android:layout_marginLeft="5dp"
    android:text="Exit Game"
    android:layout_gravity="center"
    style="@style/Button" android:layout_height="fill_parent" android:layout_width="fill_parent"/>

    </TableRow>

    </TableLayout>
</LinearLayout>
我希望它看起来像这样

| New Game |   | High Scores |
| Settings |   | Instructions|
|  About   |   |  Exit Game  |
您可以使用textview/按钮的android:weightSum和android:layout\u weight属性来分配相对宽度


这听起来可能有点奇怪,但我也建议在使用布局权重时为按钮和文本视图使用android:layout\u width=0dp。

您是否尝试过为所有文本视图设置宽度以包装内容?通过告诉指令填充父对象,它将使用尽可能宽的宽度。是的,我有它没有区别=[看起来您必须通过代码来研究如何完成此操作。
| New Game |   | High Scores |
| Settings |   | Instructions|
|  About   |   |  Exit Game  |