Programmatically Scrolling An EditText
I'm writing a simple caesar-encryption-activity. Two EditTexts on screen, one clear-text, one crypted. Here's an example for the crypted EditText - the cleartext one is similar. &l
Solution 1:
Ok, found it. It was the cursor (called Selection on EditText and TextViews).
This is how I got it to work:
ivClear // assigned the EditText that has the input
ivCrypt // assigned the target EditText, that I want to scroll
aText // the input from ivClear, crypted
Then use:
ivCrypt.setText(aText); // assign the Text
ivCrypt.setSelection(ivClear.getSelectionStart()); // scroll
Phew, finally :) Always underestimated the power of the Spannable ;)
Solution 2:
The base class android.view.View has methods getScrollX(), getScrollY() and scrollTo() that may be helpful, though I haven't tried it.
http://developer.android.com/reference/android/view/View.html#scrollTo(int, int)
Post a Comment for "Programmatically Scrolling An EditText"