0
我有一个关于我的Android应用程序的布局一个奇怪的问题(我正在学习,所以ofcourse我正在做一个计算器:))。我将所有按钮指定为行宽度的25%,但是当我在顶部添加EditText时,第一列变得比其他三列宽很多。 (屏幕截图来自IntelliJ预览版,但是当我在我的设备上加载应用程序时,结果显示如下:奇怪的布局行为 - layout_weight和按钮
当我删除EditText时,此问题消失了,我尝试在XML中向EditText添加重量属性无济于事
结果:
我的代码:
<?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="fill_parent">
<TableLayout android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:weightSum="1.0">
<TableRow android:layout_width="fill_parent"
android:weightSum="1.0">
<EditText android:layout_weight="1.0"
android:text="Edit me"></EditText>
</TableRow>
<TableRow android:layout_width="fill_parent"
android:weightSum="1.0">
<Button android:text="7"
android:layout_weight="0.25"></Button>
<Button android:text="8"
android:layout_weight="0.25"></Button>
<Button android:text="9"
android:layout_weight="0.25"></Button>
<Button android:text="/"
android:layout_weight="0.25"></Button>
</TableRow>
<TableRow android:layout_width="fill_parent"
android:weightSum="1.0">
<Button android:text="4"
android:layout_weight="0.25"></Button>
<Button android:text="5"
android:layout_weight="0.25"></Button>
<Button android:text="6"
android:layout_weight="0.25"></Button>
<Button android:text="*"
android:layout_weight="0.25"></Button>
</TableRow>
<TableRow android:layout_width="fill_parent"
android:weightSum="1.0">
<Button android:text="1"
android:layout_weight="0.25"></Button>
<Button android:text="2"
android:layout_weight="0.25"></Button>
<Button android:text="3"
android:layout_weight="0.25"></Button>
<Button android:text="-"
android:layout_weight="0.25"></Button>
</TableRow>
<TableRow android:layout_width="fill_parent">
<Button android:text="0"
android:layout_weight="0.25"></Button>
<Button android:text="."
android:layout_weight="0.25"></Button>
<Button android:text="+/-"
android:layout_weight="0.25"></Button>
<Button android:text="="
android:layout_weight="0.25"></Button>
</TableRow>
</TableLayout>
</LinearLayout>
由于在dvance。
呀,这应该工作。你更快:) – 2012-04-19 14:26:04
黄金!我忘了方向,这就是为什么我没有注意到这种方式。谢谢。 – Hidde 2012-04-19 14:34:05