Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a GridView stretchable in Android to expand the Column width to any extend?

Tags:

android

Anyone please help me with some code snippets to slove the problem.If anyone knows how to make an adjustable gridview please help me.

like image 515
Rajapandian Avatar asked Jun 12 '09 05:06

Rajapandian


People also ask

What is difference between GridView and GridLayout?

Let us not get confused with GridView and GridLayout to be the same. GridView simply gives us a two-dimensional view to display the items on the screen, under ViewGroup. On the other hand, GridLayout is a layout manager that arranges the views in a grid.

What is use of GridLayoutManager?

By using GridLayoutManager component of RecyclerView we can easily define the orientation of grid items and spanCount used for number of columns if orientation is vertical or number of rows if orientation is horizontal.

How do Gridlayouts differ from Tablelayouts?

With the TableLayout , rows and columns are added dynamically as you build the table. With the GridLayout , row and column sizes are defined in the layout definition. Neither layout is better, it's just a matter of using the best layout for your needs.


1 Answers

If you've set a specific number of columns and want the columns to expand as necessary, try gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH).

If you've instead set a specific column width and want the number of columns to change as necessary, use gridView.setNumColumns(GridView.AUTO_FIT).

like image 170
Chris Boyle Avatar answered Sep 22 '22 13:09

Chris Boyle