开发者

How to set layout_span through code

开发者 https://www.devze.com 2023-02-03 18:54 出处:网络
Does anyone know how to set/change the android:layout_span=\"\" of an EditText in Android at runtime.

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:l开发者_如何学Pythonayout_height="40dip" 
         android:id="@+id/p"
         android:layout_span="2">
    </EditText>

</TableRow>


You can use:

TableRow.LayoutParams params = (TableRow.LayoutParams)editText.getLayoutParams();
params.span = toSpan;
editText.setLayoutParams(params); // causes layout update
0

精彩评论

暂无评论...
验证码 换一张
取 消