I am currently working on an android app and i'm having some problems with EditText.
I want to create an editText with an empty string starting off with the height equivalent to 1 or more lines and maintaining that height, but allowing it to grow when text starts to overflow beneath the current size.
I tried several things :
If I set the Edittext's size to a certain value, it doesn't grow... the previous lines just go up and become invisible
When I don't set the size and use the default height, then the edittext always starts off with the height of two lines, not 1 line.
How can I fix this?
How about using these option?
android:maxHeight="100dip"
android:minHeight="40dip"
MaxHeight will force your EditText's height no more than 100dip.
MinHeight will force your EditText's height minimum is 40dip.
Example)
<EditText
android:id="@+id/somethingEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="56dip"
android:maxHeight="200dip"
android:minLines="1" />
This code will force your EditTex's height range to '56dip ~ 200dip'
You can set minimum lines using minLines Property of edittext, also use height as wrap content to make it expandable.
<EditText
android:width = "match_parent"
android:height= "wrap_content"
android:minLines="1"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With