简体   繁体   English

均匀地按出空格键(水平)

[英]Space buttons out evenly (horizontal)

I'm trying to space some buttons out across the display and have them be an equal distance apart. 我正在尝试在显示屏上隔开一些按钮,并使它们之间的距离相等。

Here's my view xml at the moment http://pastebin.com/DvURNWn3 这是我目前在http://pastebin.com/DvURNWn3上的视图xml

For each button, change this: 对于每个按钮,请更改此:

android:layout_width="0dp"

and set parent element's width fill_parent or particular width as below : 并设置父元素的宽度fill_parent或特定宽度,如下所示:

android:layout_width="40dp"

It's good practice to set root element to RelativeLayout instead of LinearLayout since nested layout_weight may throw Nested weights are bad for performance warning. 将根元素设置为RelativeLayout而不是LinearLayout是一个好习惯,因为嵌套的layout_weight可能会抛出Nested weights are bad for performance警告。

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

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