2014-03-28 48 views
2

我想把一個LinearLayout水平的一些按鈕,但我有下一個結果。如何訂購這樣的元素?

enter image description here

當他們到達屏幕的右邊,他們沒有下進行排序,他們去。我希望如果屏幕很小,它們的排列順序如下。

enter image description here

沒有削減任何按鈕。

謝謝。如果你需要我的XML,告訴我。

回答

1

嘗試將LinearLayout寬度匹配父

android:layout_width="match_parent" 
android:layout_height="wrap_content" 

希望它能幫助:)

Update:

使用GridView,並設置num_coulumsauto_fit和不斷增加的按鈕,你的願望, 集寬度&高度根據您的要求

<GridView 
    android:id="@+id/gridView1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:columnWidth="100dp" 
    android:gravity="center" 
    android:numColumns="auto_fit" 
    android:stretchMode="columnWidth" > 
</GridView> 
+0

這已經是:)。它不起作用。 – MAOL

+0

您可以創建一個自定義佈局,如[這裏]所述(http://stackoverflow.com/questions/14528381/android-horizo​​ntal-linearlayout-wrap-elements)或使用一個'GridView' – DroidUser

+0

我試圖做一個TableLayout。 – MAOL

1

你可以按照這個鏈接GridView產生這種類型的視圖更改組件