0

I want that when my edittext is empty it's height is 40px, i.e., it takes space of only one line. And when text is typed the height increases. It should function more like the WRAP_CONTENT on its height, but I want that once it reaches the height of (5*40px) or 200px, i.e., space of 5 lines. It doesn't increases anymore. It acts as if it's height is fixed 200px. How can I access this type of height feature.

Please try to help by providing Programmatic reference rather than XML reference. Thanks in advance...

Pd Unique
  • 26
  • 6

1 Answers1

0

You should check this question out. It has exactly what you need. Next time while asking a question, please do a little bit research.

Set limitation for EditText height and Maximum lines

Also, there's a tag called android:maxLines="int"or editText.setMaxLines(int numOfLines) method if you want that to set how much the EditText will stretch. It'll do exactly what you need to do.

Vedprakash Wagh
  • 3,595
  • 3
  • 12
  • 33
  • Sorry, but my problem wasn't solved. Would you please explain a bit more – Pd Unique Jun 02 '19 at 19:33
  • Check out the edited answer. It'll do exactly what you need to do. – Vedprakash Wagh Jun 02 '19 at 19:38
  • Using this results in by-default two lines height edittext even if it is empty. And what if I want to work with width not height... – Pd Unique Jun 02 '19 at 19:43
  • Your requirements are little peculiar. So you want your EditText to wrap the width? You can set `minWidth` to your editText and set `layout_width="wrap_content"` that should do the wrapping of edittext around the text. – Vedprakash Wagh Jun 02 '19 at 19:52