2011-07-21 16 views
1

你好Android的專家,如果屏幕上沒有水平空間,請轉到下一個垂直可用空間?

我有以下佈局:

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

此佈局的圖像按鈕失控屏幕和不可見。我想從新的一行開始。

任何幫助將不勝感激。

在此先感謝。 :)

+0

也許[這個問題]的第一個答案(http://stackoverflow.com/questions/549451/line-breaking-widget-layout-for-android)可以幫助你嗎? – scessor

+0

謝謝@scessor,這正是我所期待的。我真的很想感謝你:D –

回答

4

總和按鈕的像素值大於屏幕大小的像素值,並且android中沒有視圖會自動換行。如果你想讓按鈕進入下一行,你需要創建另一個佈局視圖,並在其中放置一些按鈕。

您可能還需要與佈局(S)的方向發揮:http://developer.android.com/reference/android/widget/LinearLayout.html#attr_android:orientation

此外,作爲一面,你真的應該改爲使用PX的DP或SP。 What is the difference between "px", "dp", "dip" and "sp" on Android?

+0

感謝您的回答。 :) –

+0

不客氣。 – Noah