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

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

    For EditText use

    android:layout_width="0dp" - not required but preferred.
    android:layout_weight="1"
    

    And for Button dont specify android:layout_weight

    0 讨论(0)
  • 2021-01-30 16:55

    I had the exact query. But i had an EditText and a Button next to each other in a Linear Layout. I tried android:layout_weight="1" for EditText android:layout_width="0dp" And it worked just perfect!! Thanks a lot!

    0 讨论(0)
  • 2021-01-30 17:00

    Just use:

    android:layout_width="fill_parent"
    

    for both EditText and Button. It will also work set for EditText but it is better to have it on both.

    0 讨论(0)
  • 2021-01-30 17:02

    you can define size of your edittext as it shows above

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

    or

    android:layout_width="60dp"
    

    or

    you can apply a background image of size you want but don't forget to define its height and width with wrap_content.

      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
    
    0 讨论(0)
提交回复
热议问题