GridLayout(不是GridView)如何平均拉伸所有兒童我想要一個帶有按鈕的2x2網(wǎng)格。這只是ICS,所以我嘗試使用新的GridLayout給出。下面是我布局的XML: <?xml version="1.0" encoding="utf-8"?><GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/favorites_grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00ff00"
android:rowCount="2"
android:columnCount="2">
<Button
android:text="Cell 0"
android:layout_row="0"
android:layout_column="0"
android:textSize="14dip" />
<Button
android:text="Cell 1"
android:layout_row="0"
android:layout_column="1"
android:textSize="14dip" />
<Button
android:text="Cell 2"
android:layout_row="1"
android:layout_column="0"
android:textSize="14dip" />
<Button
android:text="Cell 3"
android:layout_row="1"
android:layout_column="1"
android:textSize="14dip" /></GridLayout>問題是,對于每一行,我的視圖都不是均勻的。這會給我的GridLayout右側(cè)帶來很多額外的空間。我試著設(shè)置layout_gravity="fill_horizontal"但這只適用于最活的,剛過去的查看這一行。這意味著單元格1一直延伸到給單元格0提供足夠的空間。關(guān)于如何解決這個問題的想法?
3 回答

慕村225694
TA貢獻(xiàn)1880條經(jīng)驗 獲得超4個贊
<android.support.v7.widget.GridLayoutxmlns:android=" grid=" layout_centerHorizontal="true"grid:alignmentMode="alignBounds"grid:columnCount="4"><Button android:layout_width="0dp" style="?buttonStyle" android:layout_height="0dp" android:text="-1" grid:layout_columnWeight="1" grid:layout_rowWeight="1" grid:layout_gravity="fill"/>... ... ...
- 3 回答
- 0 關(guān)注
- 690 瀏覽
添加回答
舉報
0/150
提交
取消