Allow multi-line in EditText view in Android?

前端 未结 15 1566
既然无缘
既然无缘 2020-11-28 17:40

How to allow multi-line in Android\'s EditText view?

相关标签:
15条回答
  • 2020-11-28 18:15
     <EditText
               android:id="@id/editText" //id of editText
               android:gravity="start"   // Where to start Typing
               android:inputType="textMultiLine" // multiline
               android:imeOptions="actionDone" // Keyboard done button
               android:minLines="5" // Min Line of editText
               android:hint="@string/Enter Data" // Hint in editText
               android:layout_width="match_parent" //width editText
               android:layout_height="wrap_content" //height editText
               /> 
    
    0 讨论(0)
  • 2020-11-28 18:19

    You may find it better to use:

    <EditText 
    ...
    android:inputType="textMultiLine"
    />
    

    This is because android:singleLine is deprecated.

    0 讨论(0)
  • 2020-11-28 18:20

    I learned this from http://www.pcsalt.com/android/edittext-with-single-line-line-wrapping-and-done-action-in-android/, though I don't like the website myself. If you want multiline BUT want to retain the enter button as a post button, set the listview's "horizontally scrolling" to false.

    android:scrollHorizontally="false"

    If it doesn't work in xml, doing it programmatically weirdly works.

    listView.setHorizontallyScrolling(false);

    0 讨论(0)
提交回复
热议问题