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
Post a Comment