Creating gridlayout not working in android -
in android app, want create gridlayout of 5x5 grid. no spacing in between rows/columns. grid should match parent width/height 10dp margins. cells should have equal width , height (i.e. widths same, , heights same if width not equals height).
this have far nil shows
public class colorgrid { private context context; private relativelayout container = null; private gridlayout gridlayout = null; public colorgrid(relativelayout container) { this.context = container.getcontext(); this.container = container; this.gridlayout = creategrid(); for(int i=0; i<25; i+=1) { addcell(); } container.addview(gridlayout); } private gridlayout creategrid() { gridlayout gridview = new gridlayout(context); gridview.setcolumncount(5); gridview.setrowcount(5); relativelayout.layoutparams params = new relativelayout.layoutparams(relativelayout.layoutparams.match_parent, relativelayout.layoutparams.match_parent); params.setmargins(10, 10, 10, 10); gridview.setlayoutparams(params); homecoming gridview; } private void addcell() { view cell = new view(context); cell.setbackgroundcolor(color.parsecolor("#ffffff")); linearlayout.layoutparams params = new linearlayout.layoutparams(0, 0, 1.0f); cell.setlayoutparams(params); gridlayout.addview(cell); } public void dismiss() { if (container != null && gridlayout != null) { container.removeview(gridlayout); } } }
does know whats wrong?
thanks
android android-gridlayout
No comments:
Post a Comment