How do I change column count of a GridLayout dynamically in Android Studio? -


i want set number of column of gridlayout width of window.

but, these sort of codes don't work in oncreate() function.

gridlayout glayout = (gridlayout)findviewbyid(r.id.a_grid_layout); glayout.setcolumncount(4); 

if want set numbers of columns based on width of gridlayout, must override onmeasure method. provides widthspec , heightspec parameters, can actual width , height in pixels using measurespec.getsize(). there, calculate how many columns you'd show based on width of gridlayout found, , use setcolumncount make display number of columns.


Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -