android RelativeLayout,等间距?

我正在使用相对布局来创建一个计算器屏幕,并且我有一排标签为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"
/>

解决方法

如果你想要相等的间距,你不需要一个RelativeLayout.使用LinearLayout,就像您在问题中建议的那样.如果需要,将Buttons放在LinearLayout中,并将LinearLayout放在RelativeLayout中.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...