2个按钮并排 - 安卓布局 [英] 2 buttons side by side - android layouts

查看:2685
本文介绍了2个按钮并排 - 安卓布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么可以把2个按键并排,让他们占据了所有的宽度,与它们之间的空间不大。

我想到了一个HORIZ线性布局,设置以配合家长和重量1 2次线性布局,每个包含按钮的..有一个简单的方法?实现这一点,相对布局?

谢谢!

解决方案

 <的LinearLayout
    机器人:ID =@ + ID / LinearLayout02
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_width =FILL_PARENT
    机器人:layout_alignParentBottom =真正的>
    <按钮
        机器人:ID =@ + ID / Button02
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_weight =1机器人:文本=Übernehmen>
    < /按钮>
    <按钮
        机器人:ID =@ + ID / Button03
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_weight =1
        机器人:文本=Abbrechen>
    < /按钮>
< / LinearLayout中>
 

how can I put 2 buttons side by side, so that they occupy all the width, with a little space between them..

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?

thanks!

解决方案

<LinearLayout 
    android:id="@+id/LinearLayout02" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:layout_alignParentBottom="true">
    <Button 
        android:id="@+id/Button02" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" android:text="Übernehmen">
    </Button>
    <Button 
        android:id="@+id/Button03" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_weight="1" 
        android:text="Abbrechen">
    </Button>
</LinearLayout>

这篇关于2个按钮并排 - 安卓布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆