Caf*_*tte 3 android android-layout android-tablelayout
我有一个LinearLayout垂直方向,在第一行我添加了一个填充父母的按钮.
我想使用TableLayout实现相同的功能.
到目前为止我尝试过的是:

<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/firstRow">
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" />
</TableRow >
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
该TableRow填充母,但是行内的按钮将不会填充整个行.
如何使按钮像这样填充父母?

以及如何使它垂直填充父母像这样:

使用 android:layout_weight="1"
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow>
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Why is doing layouts on Android" />
</TableRow>
<TableRow>
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="damn" />
</TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
好像 :

| 归档时间: |
|
| 查看次数: |
1862 次 |
| 最近记录: |