'Android gridview wont fill screen - only small with scroll
My problem is the gridView is only about 1 row high with a scroll bar and I cannot get it to fill the screen. You have to scroll down to see the other rows. I don't understand what variable makes it fill the screen or the space it has available - I have tried changing the obvious ones.
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this);
Solution 1:[1]
Try setting layout_with
and layout_height
to fill_parent
in your XML layout
or
You have to set programmatically the layout params of your GridView based on its parent type like RelativeLayoutLayoutParams
, LinearLayout.LayoutParams
...
gridView.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // for example with RelativeLayout
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ChristopheCVB |