2 个按钮并排 [英] 2 buttons side by side
本文介绍了2 个按钮并排的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何并排放置 2 个按钮,使它们占据所有宽度,并在它们之间留出一点空间?
How can I put 2 buttons side by side, so that they occupy all the width, with a little space between them?
我想到了一个水平线性布局,其中 2 个子线性布局设置为匹配父级和权重 1,每个布局都包含按钮.有没有更简单的方法?这可以通过相对布局来完成吗?
I thought a horiz linear layout, with 2 sub linear layouts set to match parent and weight 1, each of them containing the button. Is there a simpler way? can this be accomplished with relative layouts?
推荐答案
<LinearLayout
android:id="@+id/LinearLayout02"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/Button02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" android:text="Apply">
</Button>
<Button
android:id="@+id/Button03"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel">
</Button>
</LinearLayout>
这篇关于2 个按钮并排的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文