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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -