<?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列按钮始终要宽一些,这是怎么回事呢?
解决方案 »
- 安装小白SDK Manager打不开
- 【咨询】想买一款便宜的Android手机,其版本Android是否可以升级?
- bitmap内存溢出的问题,大家有好的解决方案吗
- 各位SL4A用得如何了?
- 打算搞一个项目,新手,前期遇到了一些问题,望大侠帮忙
- Android 定时开关机
- 新手请教几个问题,望不吝赐教
- android 左右 选中的按钮
- 安卓java向jni传递字符串的问题
- Android软件中用户的评论功能是怎样实现的?求大牛解答。
- android 中ping功能的使用
- 有大侠知道这种错误吗?eclipse clean时候,recipe for target `clean-box2d_static-armeabi' failed
换成
android:layout_width="fill_parent"