VansFannel
VansFannel

Reputation: 45991

EditText gets bigger when I type on it

I'm developing an Android 3.1 tablet application and I have a "problem" with EditText control.

This is an EditText without text:

enter image description here

But, when I type some text on it:

enter image description here

Those four rows were created programmatically:

    LinearLayout layout = null;
    LayoutParams layoutParams = null;
    EditText editText = null;
    RadioGroup rGroup = null;
    RadioButton rButton = null;
    String tag = null;

    layout = new LinearLayout(mActivity);
    layoutParams = 
            new LayoutParams(LayoutParams.FILL_PARENT, 60);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setLayoutParams(layoutParams);

    editText = new EditText(mActivity);
    tag = Long.toString(eOtherChks.getEreportOthChkId()) + "_" + OTHER_DESCRIPTION_COL;
    editText.setTag(tag);
    layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    layoutParams.weight = .25f;
    editText.setLayoutParams(layoutParams);
    editText.setGravity(Gravity.CENTER);
    editText.setText(eOtherChks.getDescription());
    layout.addView(editText);

But, in another view, I have added some EditText programmatically with editText.setInputType(InputType.TYPE_CLASS_NUMBER); and they don't get bigger.

How can I avoid this effect?

Upvotes: 2

Views: 329

Answers (2)

VansFannel
VansFannel

Reputation: 45991

This is how I've solved the problem:

layoutParams = new LayoutParams(0, LayoutParams.WRAP_CONTENT);

Upvotes: 0

Thiago Moura
Thiago Moura

Reputation: 358

You can try setting:

layoutParams.width = 0;

This should prevent the resize. Let me know if it works.

Upvotes: 1

Related Questions