简体   繁体   中英

Android multiline EditText

I've one EditText with multi-lines.

The problem is that, while I am adding more and more lines, just pressing ENTER or typing, the EditText keeps scrolling down which is OK, but after approx. 10 lines whole activity is scrolling.

And when I click again on EditText , the opened keyboard covers whole EditText .

But, when I click only on 3rd line, keyboard isn't covering EditText and View is moved like it should have.

Any advice please?

Okay,Using EditText in ScrollView Like this way

 <ScrollView 
    android:layout_height="100dp"
    android:layout_width="match_parent">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="#54D66A"
        android:textSize="17sp" />

</ScrollView>

For programmatic approach please check

http://developer.android.com/reference/android/text/method/ScrollingMovementMethod.html

You can give android:maxHeight="60dp" to your EditText to stop scrolling of the whole Activity and it will solve other problem also.

I hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM