2012-05-03 31 views
1

我跟着這個教程:的Android GridView控件不會填滿屏幕 - 只有少量帶滾動

http://mytelcoit.com/2010/02/programming-android-create-icon-with-text-using-gridview-and-layout-inflater/

所以我的代碼是一樣的。我的問題是gridView只有大約1行高滾動條,我無法讓它填滿屏幕。您必須向下滾動以查看其他行。我不明白什麼變量使它填滿屏幕或它有空間 - 我試圖改變明顯的。

 GridView gridview = (GridView) findViewById(R.id.gridview); 

    gridview.setAdapter(new ImageAdapter(this); 
+0

您是否嘗試過使用GridVie的'layout_weight'屬性w'?該屬性使視圖佔用儘可能多的空間。 – Dan

回答

0

嘗試在你的XML佈局設置layout_withlayout_heightfill_parent

你必須設置編程基於像RelativeLayoutLayoutParams其父類型,LinearLayout.LayoutParams你的GridView的佈局參數...

gridView.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // for example with RelativeLayout 
+0

我已經嘗試了所有上述 - 它只是沒有影響:( – user1212520