android - Set layout_column and layout_row in GridLayout programmatically -
i have gridlayout (not gridview) want add views special row , column inex. in xml can set view with:
<textview android:id="@+id/textview1" android:layout_column="2" android:layout_row="4" android:text="large text" />
but how can set attributes layout_column
, layout_row
programmatically? want this:
gridlayout grid = new gridlayout(getactivity()); grid.setcolumn(2); grid.setrow(4); grid.addview(new button(getactivity());
the equivalent of layout_column
, layout_row
, layout_...
parameters, found parameter of subclass of layoutparams
.
in case it's gridlayout.layoutparams
, , use (for 2x2 grid subview in final row , column, centred within cell):
gridlayout.setcolumncount(2); gridlayout.setrowcount(2); gridlayout.addview(subview, new gridlayout.layoutparams( gridlayout.spec(1, gridlayout.center), gridlayout.spec(1, gridlayout.center)));
Comments
Post a Comment