tags:

views:

153

answers:

1

Hi,

I was wondering if it's possible to set an automatic/dynamic margin (padding?) between elements in an Android layout without having to do it programmatically?

For example let's say there is a horizontal LinearLayout which is set to android:layout_width="fill_parent" and that contains five elements. Is there a setting that evenly shares the remaining empty space of the LinearLayout to the margins of the child elements?

See image at http://img63.imageshack.us/img63/8/margin.png

Thanks for any help!

A: 

Yup. Only LinearLayouts support it. Tis called layout weight

Look for LinearLayout at http://developer.android.com/guide/topics/ui/layout-objects.html

For a good intro, look here

Hamy
Can you please give an example of the layout XML? I thought the weight attribute gives some of the remaining space to an element. I was talking about the margins though.
Sven