1

Hello Android Experts,

I have the following layout:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<ImageButton android:id="@+id/ImageButton01"
android:layout_width="80px" 
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
<ImageButton android:id="@+id/ImageButton02"
android:layout_width="80px" 
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
<ImageButton android:id="@+id/ImageButton01"
android:layout_width="80px" 
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
<ImageButton android:id="@+id/ImageButton02"
android:layout_width="80px" 
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
<ImageButton android:id="@+id/ImageButton01"
android:layout_width="80px" 
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
<ImageButton android:id="@+id/ImageButton02"
android:layout_width="80px" 
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
</LinearLayout>

The image buttons of this layout gets out of the screen and become invisible. I would like to start from a new line.

Any help will be appreciated.

Thanks in advance. :)

inazaruk
  • 74,247
  • 24
  • 188
  • 156
M.ES
  • 920
  • 14
  • 30
  • Maybe the first answer of [this question](http://stackoverflow.com/questions/549451/line-breaking-widget-layout-for-android) can help you? – scessor Jul 21 '11 at 18:46
  • Thank you @scessor, this is exactly what I was looking for. I would Really like to thank you :D – M.ES Jul 22 '11 at 11:46

1 Answers1

4

The pixel values of the sum buttons is larger than the pixel value of the screen size, and there is no view in android that will automatically wrap a line. If you want the buttons to go to the next line, you will need to create another layout view and place some of the buttons in there.

You may also want to play with the orientation of the layout(s): http://developer.android.com/reference/android/widget/LinearLayout.html#attr_android:orientation

Also, as a side, you should really be using dp or sp instead of px. What is the difference between "px", "dp", "dip" and "sp" on Android?

Community
  • 1
  • 1
Noah
  • 1,966
  • 1
  • 14
  • 29