How tot scroll to end of an android TextView?
I have a android.widget.EditText
(in multi line read only mode) in which I display some informations (the left half):
From time to time additional informations are added to the end of this android.widget.EditText
and then I would like to scroll to the end of the the field (perhaps only scrolling to the end if already positions at the end which I think is even more user friendly).
Surprisingly I was unable to find any information on cursor and scroll movement in android.widget.EditText
.
I found this posting bu开发者_如何学Got i don't have a ScrollView
and I wonder why would I want one as a android.widget.EditText
can handle it own scolling.
Any ideas or insights? What did I miss?
If scrolling to the end is all you want then the following will do:
this.Printout.setText ("");
this.Printout.append (Service.Get_FP10_Printout ());
The trick here: android.widget.EditText.append
will scroll to the end of the field for you. So I delete the text and then append what I want to display.
If you need any other scrolling then you need to envelop the android.widget.TextView
with an android.widget.ScollView
(as lumis suggested) and use the trick from Patrick.
You know, Casio FX602P was my very first programmable computer!
I am not sure if editView can be made to scroll on its own, but if you envelop a textView with a scrollView and disable the scroll bars you should get what you need.
One other possibility came to my mind; if you use a List instead that would allow not just to scroll but to select the line of code which one wants to edit in the display on the right...
To accomplish this you must wrap the EditText in a ScrollView and control it through it's parent. It was previously possible to simply use EditText.append to accomplish this as indicated by one of the answers append here. However google has made all standard EditText's AppCompat now which has changed the behavior of the append function, it no longer scrolls to the end.
I found out the hard way as my app's functionality changed after a compile with the newer API.
精彩评论