简体   繁体   中英

Align buttons with equal margin in linear layout

I need my buttons to be placed equally apart from each other. I have five circular buttons where the center one is the largest in size. I tried out by setting weightSum and assigning weight in each button but this method causes my round button to distort, each button becoming an oval shape. Since one of my button is bigger than all the other ones, setting equal weight doesn't seem to solve my problem. I'd like to know if there is a way to set equal margin between buttons without 1. distorting shape of buttons 2. manually setting dp values of margin

You can wrap each of your button view in a parent layout say for ex. FrameLayout and then you can use your weightSum Technique to get equal margins between each button. as in this case your button's size will remain constant and the parent layout's size will increase.So I think it can be solve your case.

You can set orientation as vertical and set rows as needed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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