在我的应用程序中,我有一个可滚动的TextView,但滚动不像ListView那样平滑。
我希望有相同的滚动"效果"像listview(弹跳,加速,...)
这是我的代码:
sNotes.setMovementMethod(new ScrollingMovementMethod());
sNotes.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
boolean isLarger;
isLarger = ((TextView) v).getLineCount()
* ((TextView) v).getLineHeight() > v.getHeight();
if (event.getAction() == MotionEvent.ACTION_MOVE
&& isLarger) {
v.getParent().requestDisallowInterceptTouchEvent(true);
moveY = event.getY();
touchDown = false;
} else {
v.getParent().requestDisallowInterceptTouchEvent(false);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
touchY = event.getY();
touchDown = true;
}
else if (event.getAction() == MotionEvent.ACTION_UP) {
float uptouchy = event.getY();
if (touchY == uptouchy) {
expandNotes = false;
myParent.expandNotes = false;
notifyDataSetChanged();
}
}
}
return false;
}
});