【发布时间】:2011-04-23 15:47:39
【问题描述】:
我正在使用相对布局来创建计算器屏幕,并且我有一排标记为 1、2 和 3 的按钮。我希望它们均匀分布,但我不确定如何使用相对布局
我习惯在LinearLayout中使用android:layout_weight函数,给它们每一个赋值一个android:layout_width="fill_parent",还有一个layout_weight="1"
在计算器屏幕上实现这一点的任何方法(不指定 DP 或 PX)
这是我目前设置的,它们在 TextView(计算器输出屏幕)下按从左到右的顺序排列。对均匀空间、填充屏幕宽度有什么建议/解决方案?
<TextView
android:id="@+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_text"
android:layout_margin="6px"
/>
<Button
android:id="@+id/button1"
android:text="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
/>
<Button
android:id="@+id/button2"
android:text="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:layout_toRightOf="@+id/button1"/>
<Button
android:id="@+id/button3"
android:text="3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:layout_toRightOf="@+id/button2"
/>
【问题讨论】:
标签: android android-relativelayout