Anyone please help me with some code snippets to slove the problem.If anyone knows how to make an adjustable gridview please help me.
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.
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.
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.
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)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With