如何设置的EditText框的高度,并在机器人编程宽 [英] how to set EditText box height and width programmatically in android

查看:288
本文介绍了如何设置的EditText框的高度,并在机器人编程宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我想在Android中,我试图程序化管理的EditText框的高度和宽度 edittext.setWidth(32); edittext.setEms( 50); 两者都不能正常工作,请参阅我的下面的编码coze我使用它来创建动态的EditText android系统

 私人的EditText createEditText()
    {
        最后的LayoutParams lparams =新的LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
        最后的EditText的EditText =新的EditText(本);
        edittext.setLayoutParams(lparams);
        edittext.setWidth(32);
        edittext.setEms(50);
        返回的EditText;
    }
 

解决方案

 私人的EditText createEditText()
{
    最后的LayoutParams lparams =新的LayoutParams(50,30); //宽,高
    最后的EditText的EditText =新的EditText(本);
    edittext.setLayoutParams(lparams);
    返回的EditText;
}
 

试试这个。

hey i want to manage height and width of EditText Box programmatically in android i tried edittext.setWidth(32); and edittext.setEms(50); both are not working please see my below coding coze i am using it to create dynamic EditText 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;
}

Try this.

这篇关于如何设置的EditText框的高度,并在机器人编程宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆