android - adding layoutWeightSum in a table row through java -
i want show table row 3 columns (textview
) want divide table row in 3 equal parts.
this possible setting layoutweightsum in tablerow in xml , making layout_weight=1 theww textview
.
but adding table @ run time through java , not xml.
all know tablerow.layoutparameter not provide thing weightsum. how can this?
tablerow.layoutparams pmrow = new tablerow.layoutparams(tablerow.layoutparams.match_parent, tablerow.layoutparams.wrap_content);
you can achieve following code.
tablelayout layout = //...findviewbyid layout.setstretchallcolumns(true);
and make width 0dp
children (views) of tablerow
below.
<textview android:id="@+id/txt_no1" android:layout_width="0dp" android:layout_height="wrap_content" android:text="hi" />
note
above xml layout design, can create run time code also. demonstration.
Comments
Post a Comment