[Android Q&A, Help & Troubleshooting] Александръ:
When trying to implement an EditText scrolling method, I found that ScrollView apparently can only scroll one page at a time.

To go around that limitation, I decided to scroll my EditText (instead of the ScrollView) by the desired number of pixels. However, the problem is, as soon as I move my cursor, TextEdit updates the view back to the way it was (i.e., equivalent of ScrollTo(0, 0)). So if I need to scroll by 240 pixels, it either scrolls so that I am at the top of Page 1 (0 pixels), or the top of Page 2 (727 pixels).

Does anyone know of some way to go around this limitation without executing "ScrollTo" at the end of every keystroke? I am sure there should be some option to set AutoScroll=Off, or something along those lines...

Edit: and I would prefer to keep the ScrollView there, since I would like my user to be able to scroll using gestures as well. Though it is okay if the user has to push a button to turn off gesture scrolling to allow EditText.scrollBy scrolling, but not both.

OLD QUESTION:

Hello,

I would like to edit some really long texts using the EditText app. When the text gets so large that it does not fit on the screen, the EditText does not automatically scroll to where the cursor is: so I stop being able to see where I'm typing.

I decided to allocate the top and bottom soft keys to allow me to scroll quickly. I tried several functionalities of the soft keys, but they all failed to resolve this problem:

1. Send a command to my EditText to ScrollBy a certain number of pixels. However, at that point I cannot use scrolling gestures to scroll back up to where I was.

2. Send a sequence of TouchEvents to emulate the scrolling, e.g.:

scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1000, MotionEvent.ACTION_DOWN, 100, 200, 0));
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1100, MotionEvent.ACTION_MOVE, 100, 190, 0));
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1200, MotionEvent.ACTION_MOVE, 100, 180, 0));
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1300, MotionEvent.ACTION_MOVE, 100, 170, 0));
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1400, MotionEvent.ACTION_MOVE, 100, 160, 0));
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1500, MotionEvent.ACTION_MOVE, 100, 150, 0));
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1600, MotionEvent.ACTION_UP, 100, 140, 0));

However, regardless of playing around with the parameters, and whether the command is sent to my ScrollView or to my EditText, I was still unable to emulate scrolling via a command.

3. Determine where I am using EditText.getLayout.getLineBottom, and then touch that area. For scroll up, that worked good enough; for scroll down, though, if I touch my line, it comes up at the bottom; however, my line is then concealed by the soft keyboard. If I touch below my line, and then update my position, the updating of position happens faster than the touch, and at the end, my position ends up below where I should be.

4. I also tried playing around with different parameters in the XML of my file. Also, no success.

Any suggestions?