I have implemented the editor code from the Android Note Pad sample code. Now I would like to add the ability to vertically fling scrolls the lines of text. An example of what I
This is a simpler version, which is basically the same at the scoller level. It's not perfect but gives another way of looking at it.
final TextView textview = ((TextView) VIEW.findViewById(R.id.text));
final Scroller scroller = new Scroller(CONTEXT);
textview.setText(TEXT);
textview.setMovementMethod(new ScrollingMovementMethod());
textview.setScroller(scroller);
textview.setOnTouchListener(new View.OnTouchListener() {
// Could make this a field member on your activity
GestureDetector gesture = new GestureDetector(CONTEXT, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
scroller.fling(0, textview.getScrollY(), 0, (int)-velocityY, 0, 0, 0, (textview.getLineCount() * textview.getLineHeight()));
return super.onFling(e1, e2, velocityX, velocityY);
}
});
@Override
public boolean onTouch(View v, MotionEvent event) {
gesture.onTouchEvent(event);
return false;
}
});