如果屏幕上没有水平空间,请转到下一个垂直可用空间?

时间:2011-07-21 18:31:46

标签: android android-layout android-linearlayout

Hello Android Experts,

我有以下布局:

<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>

此布局的图像按钮离开屏幕并变得不可见。我想从一个新的界线开始。

任何帮助将不胜感激。

提前致谢。 :)

1 个答案:

答案 0 :(得分:4)

和按钮的像素值大于屏幕大小的像素值,并且android中没有自动换行的视图。如果您希望按钮转到下一行,则需要创建另一个布局视图并在其中放置一些按钮。

您可能还想使用布局的方向:http://developer.android.com/reference/android/widget/LinearLayout.html#attr_android:orientation

另外,作为一方,你应该使用dp或sp而不是px。 What is the difference between "px", "dp", "dip" and "sp" on Android?

相关问题