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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -