iuq
iuq

Reputation: 1529

Even distribution of views in a layout

Is there any way, I can add UI components (Buttons in my case) to any layout (RelativLayout in my case) and width of parent gets evenly distributed among all views.

say parent width = 100;

if I add 10 Buttons - all buttons should be of width 10.

thanks. m

Upvotes: 0

Views: 107

Answers (1)

aqs
aqs

Reputation: 5682

If you use a LinearLayout you can make use of layout_weight to evenly distribute the size.
For eg, if you have two buttons, to take half width each of its parent, you can give "layout_weight=1" in both the buttons. So both of them would share the space. Checkout the layout_weight documentation for more details

Upvotes: 1

Related Questions