简体   繁体   English

如何在按钮之间分配剩余空间

[英]how to distribute leftover space between buttons

Is there any way i can accomplish the following, i've looked around but can't seem to find a solution: 我有什么办法可以完成以下工作?我环顾四周,但似乎找不到解决方法:

I have 5 buttons inside a LinearLayout and Im defining the buttons width and height programmatically. 我在LinearLayout和Im中有5个按钮,它们以编程方式定义按钮的宽度和高度。 There is no space between the buttons, so it looks like this: 按钮之间没有空格,因此看起来像这样:

(x=button)
|    xxxxx    |

How can I tell the layout to distribute any leftover space on either side of the group of buttons to be evenly distibuted BETWEEN the buttons, making the layout look like this: 如何告诉布局在按钮组的两侧分配剩余的空间,以便在按钮之间均匀分配,使布局看起来像这样:

(x=button)
| x x x x x | 

According to me, this ain't possible with attributes of your LinearLayout. 据我说,这是无法使用LinearLayout的属性实现的。

You can choose to add an empty view or spacer between your buttons, or give your buttons margin or padding where needed. 您可以选择在按钮之间添加空白视图或间隔,或在需要时为按钮留出边距或填充。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM