0

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

iuq
  • 1,487
  • 1
  • 20
  • 42

1 Answers1

1

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

aqs
  • 5,632
  • 3
  • 24
  • 24
  • thanks, it works. Also found another link discussing problem http://stackoverflow.com/questions/2698817/linear-layout-and-weight-in-android – iuq Jan 20 '12 at 11:29