我想在 Android 中以编程方式管理 EditText
框的高度和宽度.我尝试了 edittext.setWidth(32);
和 edittext.setEms(50);
,但两者都不起作用.请参阅下面的代码,因为我正在使用它在 Android 中创建动态 EditText
.
I want to manage the height and width of an EditText
box programmatically in Android. I tried edittext.setWidth(32);
and edittext.setEms(50);
, but both are not working. See my below code, as I am using it to create dynamic EditText
s in Android.
private EditText createEditText()
{
final LayoutParams lparams = new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
final EditText edittext = new EditText(this);
edittext.setLayoutParams(lparams);
edittext.setWidth(32);
edittext.setEms(50);
return edittext;
}
private EditText createEditText()
{
final LayoutParams lparams = new LayoutParams(50,30); // Width , height
final EditText edittext = new EditText(this);
edittext.setLayoutParams(lparams);
return edittext;
}
试试这个.
这篇关于如何在 Android 中以编程方式设置 EditText 框的高度和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!