我有這樣的代碼:Android的網格佈局四溢屏幕
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="8"
android:rowCount="8" >
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
</GridLayout>
而且它給我這個:
它應該是一個8x8的網格,但它四溢。我如何以非編程方式(通過xml)適合64個方格?
看起來您的圖片對於網格佈局來說太大,以至於在使用行數時適合屏幕。也許[這](http://stackoverflow.com/a/10033481/758341)將幫助 – balysv