<?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" > <EditText
android:id="@+id/editPromot1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="13"
android:enabled="false"
android:focusableInTouchMode="false"
android:inputType="number" /> <EditText
android:id="@+id/editPromot2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="13"
android:enabled="false"
android:focusableInTouchMode="false"
android:inputType="" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" > <EditText
android:id="@+id/editNumber"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="4"
android:ems="13"
android:enabled="false"
android:focusableInTouchMode="false" > <requestFocus />
</EditText> <ImageButton
android:id="@+id/imageDelete"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/sym_keyboard_delete" /> </LinearLayout> <TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5" > <TableRow
android:id="@+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3dp" > <Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="1" /> <Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="2" /> <Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3" /> </TableRow> <TableRow
android:id="@+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3dp" > <Button
android:id="@+id/btn4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="4" /> <Button
android:id="@+id/btn5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="5" /> <Button
android:id="@+id/btn6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="6" /> </TableRow> <TableRow
android:id="@+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3dp" > <Button
android:id="@+id/btn7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="7" /> <Button
android:id="@+id/btn8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="8" /> <Button
android:id="@+id/btn9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="9" /> </TableRow> <TableRow
android:id="@+id/tableRow4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3dp" > <Button
android:id="@+id/btnx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="*" /> <Button
android:id="@+id/btn0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="0" /> <Button
android:id="@+id/btnj"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#" /> </TableRow> <TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" > <ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/sym_action_call" /> </TableRow> </TableLayout>
</LinearLayout>TableLayout是4行,每行3个按钮,3个按钮的weight都是1,但是第1列按钮始终要宽一些,这是怎么回事呢?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <EditText
android:id="@+id/editPromot1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="13"
android:enabled="false"
android:focusableInTouchMode="false"
android:inputType="number" /> <EditText
android:id="@+id/editPromot2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="13"
android:enabled="false"
android:focusableInTouchMode="false"
android:inputType="" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" > <EditText
android:id="@+id/editNumber"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="4"
android:ems="13"
android:enabled="false"
android:focusableInTouchMode="false" > <requestFocus />
</EditText> <ImageButton
android:id="@+id/imageDelete"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/sym_keyboard_delete" /> </LinearLayout> <TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5" > <TableRow
android:id="@+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3dp" > <Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="1" /> <Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="2" /> <Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3" /> </TableRow> <TableRow
android:id="@+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3dp" > <Button
android:id="@+id/btn4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="4" /> <Button
android:id="@+id/btn5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="5" /> <Button
android:id="@+id/btn6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="6" /> </TableRow> <TableRow
android:id="@+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3dp" > <Button
android:id="@+id/btn7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="7" /> <Button
android:id="@+id/btn8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="8" /> <Button
android:id="@+id/btn9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="9" /> </TableRow> <TableRow
android:id="@+id/tableRow4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3dp" > <Button
android:id="@+id/btnx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="*" /> <Button
android:id="@+id/btn0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="0" /> <Button
android:id="@+id/btnj"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#" /> </TableRow> <TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" > <ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/sym_action_call" /> </TableRow> </TableLayout>
</LinearLayout>TableLayout是4行,每行3个按钮,3个按钮的weight都是1,但是第1列按钮始终要宽一些,这是怎么回事呢?
换成
android:layout_width="fill_parent"