How do I prevent an EditText from resizing itself when the user is typing?

前端 未结 10 2081
粉色の甜心
粉色の甜心 2021-01-30 16:18

I have an EditText and a Button set next to each other on the same horizontal line. It looks great, except when the user enters a lot of text, the

10条回答
  •  轮回少年
    2021-01-30 16:46

    What I do is in the onCreate for the activity, measure the EditText first then apply its maxWidth.

    You can do so using code similar to the following:

    EditText someedittext = (EditText)findViewById(R.id.sometextview);
    someedittext.setMaxWidth(someedittext.getWidth());
    

提交回复
热议问题