How to wrap Image buttons in a horizontal linear layout?
You could use FlowLayout for this.
Check this
EDITED
Add the required class, styles and attributes to your project from the link i gave you. And use this layout, by adding it to your layout XML.
Mentioned in the Git Project.. Copy all the files from Git Project to your projects
User FlowLayout instead LinearLayout in XML
<com.yourpackage.FlowLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</com.yourpackage.FlowLayout>
And then add your child view in that FlowLayout, may be in XML only or at run time.
Other Parameters supported are :
xmlns:f="http://schemas.android.com/apk/res/your.namespace"
f:horizontalSpacing="6dip"
f:verticalSpacing="12dip"
f:orientation="vertical"
f:layout_horizontalSpacing="32dip"
f:layout_verticalSpacing="32dip"
I have added a support to fit the content in a line. Get my github source
To make this work. you need to give one more attribute as fitContent to true for your layout.
f:fitContent="true"
Answer for your Comments
f:verticalSpacing="12dip" - Is used to specify the vertical spacing for the whole FlowLayout. i.e Every child view/button will have the vertical spacing.
Example
<org.apmem.tools.layouts.FlowLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
f:verticalSpacing="12dip"
>
</org.apmem.tools.layouts.FlowLayout>
Whereas, f:layout_verticalSpacing="32dip" is specified to a child button as we specify the weight
Example
<Button
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
f:layout_verticalSpacing="32dip"
>
</Button>