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

前端 未结 10 1980
粉色の甜心
粉色の甜心 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:48

    The correct way to do this would be to set the android:minWidth and android:maxWidth equal to the width you want. This way you will not have to adjust your layout to use the android:layout_weight.

    For example if you want your EditText to always be 80 density pixels no matter how many characters you type in use the following:

    android:minWidth="80dp"
    android:maxWidth="80dp"
    

提交回复
热议问题