布局按钮,使每一个划分了空间同样 [英] Layout buttons so each divides up the space equally

查看:155
本文介绍了布局按钮,使每一个划分了空间同样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用我是个LinearLayout中放两个按钮水平并排的一面,但我想每个按钮的大小本身使用50%的水平空间。我想layout_weight1为每个按钮会做的伎俩,但也许我layout_width需要更改?

Im using a LinearLayout to put two buttons horizontally side-by-side, but I want to each button to size itself to use 50% of the horizontal space. I thought layout_weight of "1" for each button would do the trick, but maybe my layout_width needs to be changed?

推荐答案

layout_weight 属性控制多少钱的遗留下来的的空间的每一个您的按钮给出。如果你的按钮占用不同的空间量入手,那么每个人都会首先给他们所要求的空间,而的任何剩余空间将被划分它们之间,这意味着你赢了'T有一个确切的50/50。

The layout_weight attribute controls how much of the left over space each of your buttons is given. If your buttons take up different amounts of space to start with, then each of them will first be given the space they ask for, and then any remaining space will be divided up between them, meaning that you won't have an exact 50/50 split.

您可以通过先设定得到解决此问题 layout_width =0px​​(保持你的 layout_weight 取值为他们是),依靠50%是足够的空间来显示每个按钮。

You can get around this behaviour by first setting layout_width="0px" (keeping your layout_weights as they are), and relying on 50% being enough space to display each button.

这篇关于布局按钮,使每一个划分了空间同样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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