Android的RelativeLayout的,间距相等? [英] android RelativeLayout, equal spacing?
问题描述
我使用的是相对布局创建一个计算器屏幕,和我有一排标有1,2个按钮,和3。我希望他们均匀分布的,但我不知道如何与相对布局<做到这一点/ P>
我已经习惯了使用了android:layout_weight功能的LinearLayout,并给他们每个人的android值:layout_width =FILL_PARENT,以及一个layout_weight =1
什么办法让这种情况发生在计算器屏幕(不指定DP或PX)
这是我所成立的那一刻,他们的顺序排列,从左至右,在TextView的(计算器输出屏幕)。任何建议/解决方案,以均匀的空间,尽显画面的宽度是多少?
&LT;的TextView
机器人:ID =@ + ID / TextView的
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@可绘制/ edit_text
机器人:layout_margin =6px
/&GT;
&LT;按钮
机器人:ID =@ + ID /按钮1
机器人:文本=1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / TextView的
/&GT;
&LT;按钮
机器人:ID =@ + ID /按钮2
机器人:文本=2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / TextView的
机器人:layout_toRightOf =@ + ID /按钮1/&GT;
&LT;按钮
机器人:ID =@ + ID /按钮3
机器人:文本=3
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / TextView的
机器人:layout_toRightOf =@ + ID /按钮2
/&GT;
如果你想间距相等,你不想要一个 RelativeLayout的
。使用的LinearLayout
,你建议你的问题。如果需要的话,把按钮
在的LinearLayout
,把的LinearLayout
在 RelativeLayout的
。
I'm using Relative Layout to create a calculator screen, and i have a row of buttons labeled 1, 2, and 3. I want them evenly spaced, but i'm not sure how to do this with Relative Layout
I'm used to using the android:layout_weight function in LinearLayout, and give each of them a value of android:layout_width="fill_parent", as well as a layout_weight="1"
any way to get this to happen on calculator screen (without specifying DP or PX)
this is what i have set up at the moment, and they are aligned in order from left to right, under the TextView (calculator output screen). any suggestions/solutions to evenly space, filling the width of the screen?
<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"
/>
If you want equal spacing, you do not want a RelativeLayout
. Use a LinearLayout
, as you suggest in your question. If needed, put the Buttons
in a LinearLayout
and put the LinearLayout
in the RelativeLayout
.
这篇关于Android的RelativeLayout的,间距相等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!