【发布时间】:2011-04-21 20:20:03
【问题描述】:
我正在开发一个 Android 应用程序。
我有这个:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="200px"
android:orientation="vertical">
<TextView
android:id="@+id/gameTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="left"
android:layout_margin="5px"
android:text="aaaaa"/>
<TextView
android:id="@+id/gameDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="left"
android:layout_margin="5px"
android:typeface="sans"
android:textSize="16sp"
android:textStyle="bold"
android:text="dddddd"/>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ButtonsTable"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:text="@string/yes"
android:id="@+id/playGame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:text="@string/no"
android:id="@+id/noPlayGame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
</LinearLayout>
我想把playGame按钮放在中间的左边,把noPlayGame按钮放在中间的右边。
现在,两者都显示在 TableRow 的左侧。
我该怎么做?
谢谢。
编辑:我添加了完整的布局和 Ashay 建议的修改。
第二次编辑:
解决方案
我已将以下内容添加到 TableLayout:android:stretchColumns="0,1"。现在按钮居中对齐,但它们填满了整个列!!!
【问题讨论】:
-
可能值得发布您自己的答案并将其标记为已回答,这样就不会一直出现在未回答的问题列表中。
-
我不喜欢回答我自己的问题。
-
就是这样。谢谢。您的解决方案工作。
标签: android tablelayout