Does anyone know how to set/change the android:layout_span=""
of an EditText in Android at runtime. I already have the EditText defined in my XML file.
<TableRow android:paddingTop="20dip" android:gravity="center_horizontal"> <EditText android:layout_width="150dip" android:text="" android:layout_height="40dip" android:id="@+id/p" android:layout_span="2"> </EditText> </TableRow>
android:layout_span. Defines how many columns this child should span.
This set of layout parameters defaults the width and the height of the children to ViewGroup. LayoutParams. WRAP_CONTENT when they are not specified in the XML file. RelativeLayout.LayoutParams. Specifies how a view is positioned within a RelativeLayout .
Stretching layout using Layout SpansThe amount of space given to each element, is specified in the android:layout_span attribute, which tells us how many columns it will span over.
You can use:
TableRow.LayoutParams params = (TableRow.LayoutParams)editText.getLayoutParams(); params.span = toSpan; editText.setLayoutParams(params); // causes layout update
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With