2011-10-31 17 views
3

我已經做了一個gridview,我添加了圖像。但我的問題是,它顯示了非常小的gridview,其中只有3張圖像,如圖中所示,我想在其中顯示9張圖像。android:gridview

enter image description here小號

但是我想,在GridView大小爲填補父項下面的照片和底部上方的滾動條。

我使用下面的XML它

   <RelativeLayout android:layout_height="fill_parent" 
     android:layout_width="fill_parent" android:layout_above="@+id/LinearLayouToolbar" 
     android:layout_below="@+id/linearLayout3"> 
     <ScrollView android:layout_height="200dp" 
      android:layout_width="320dp" android:id="@+id/scrollView1" 
      android:layout_alignParentTop="true" android:layout_alignParentLeft="true"> 



      <GridView android:horizontalSpacing="10dp" 
       android:columnWidth="80dp" android:verticalSpacing="20dp" 
       android:stretchMode="columnWidth" android:padding="10dp" 
       android:id="@+id/GridView01" android:fastScrollEnabled="true" 
       android:layout_gravity="fill|center" android:numColumns="auto_fit" 
       android:layout_marginBottom="0dp" android:layout_width="wrap_content" 
       android:layout_height="wrap_content"></GridView> 
     </ScrollView> 
    </RelativeLayout> 
+1

你可以發佈整個佈局? – Raz

+2

在滾動視圖內不使用gridview。 android:layout_width =「wrap_content」 android:layout_height =「wrap_content」 並將上面的屬性設置爲fillparent。 –

+0

由於您將scrollview的高度設置爲200dp,因此它將gridview放置在分配的高度之內。 –

回答

5

糾正你的滾動視圖的寬度和高度爲:

<ScrollView android:layout_height="fill_parent" 
      android:layout_width="fill_parent" android:id="@+id/scrollView1" 
      android:layout_alignParentTop="true" android:layout_alignParentLeft="true"> 

否則刪除了滾動,只要給GridView中RelativeLayout的內部。

+2

爲完美的解決方案1+ –

+0

刪除滾動視圖工作完全謝謝:) – ekjyot

+0

它是相當禁止將一個gridview放在滾動視圖,反正 – njzk2

5

你不應該把滾動視圖內一個gridview(以及列表視圖)。在你的情況下,它看起來是多餘的,因爲gridview會爲自己提供滾動。

+0

感謝它的工作:) – ekjyot