How to allow multiple lines in the edit text view of Android?
#1 building
This is useful for me, in fact these two attributes are important: inputType and lines. In addition, you may need a scroll bar, and the following code shows how to make one:
<EditText android:id="@+id/addr_edittext" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="top|left" android:inputType="textEmailAddress|textMultiLine" android:lines="20" android:minLines="5" android:scrollHorizontally="false" android:scrollbars="vertical" />
#2 building
All of this is fine, but if you have your edittext in the upper scrolling view, it won't work:) perhaps the most common example is the settings view, which has many projects beyond the visible area. In this case, you place them all in the scroll view so that the settings scroll. If you need multiple lines of scrollable edit text in the settings, its scrolling will not work.
#3 building
Try this, add these lines to the edit text view, and I'll add mine. Make sure you understand it
android:overScrollMode="always" android:scrollbarStyle="insideInset" android:scrollbars="vertical" <EditText android:inputType="textMultiLine" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/editText_newprom_description" android:padding="10dp" android:lines="5" android:overScrollMode="always" android:scrollbarStyle="insideInset" android:minLines="5" android:gravity="top|left" android:scrollbars="vertical" android:layout_marginBottom="20dp"/>
And in your java class make click listner to edit the text as follows, I will add my change name according to your.
EditText description; description = (EditText)findViewById(R.id.editText_newprom_description); description.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { view.getParent().requestDisallowInterceptTouchEvent(true); switch (motionEvent.getAction() & MotionEvent.ACTION_MASK){ case MotionEvent.ACTION_UP: view.getParent().requestDisallowInterceptTouchEvent(false); break; } return false; } });
It's good for me
#4 building
I from http://www.pcsalt.com/android/edittext-with-single-line-line-wrapping-and-done-action-in-android/ Understand this, though I don't like the site myself. If you want more than one line but want to keep the input button as the Publish button, set the horizontal scroll of listview to false.
android:scrollHorizontally="false"
If it doesn't work in xml, it's strange to execute it programmatically.
listView.setHorizontallyScrolling(false);
#5 building
To disable the number of rows previously allocated in the topic usage xml attribute: Android: lines = @ null