今天写安卓app的时候遇到一个问题。就是我想实现的效果是在一个textview控件中可以实现上下滚动阅读文字。并且左右滑动可以实现翻页功能,但在实现过程中发现当设置左右的监听事件后,原来的滚动条效果就失效了。我安卓基础不太好,请问该如何解决
TextView1.setMovementMethod(ScrollingMovementMethod.getInstance());
TextView1.setOnTouchListener(new View.OnTouchListener() {
// @Override
// public
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
//按下
case MotionEvent.ACTION_DOWN:
pressX = event.getX();
pressY = event.getY();
break;
//移动
case MotionEvent.ACTION_MOVE:
moveX = event.getX();
moveY = event.getY();
break;
//松开
case MotionEvent.ACTION_UP:
if (moveX - pressX > 0 && Math.abs(moveY - pressY) < 50) {
ym=ym-1;
Intent intent = new Intent(BookContent.this, BookContent.class);
Bundle bundle = new Bundle();
bundle.putString("sjdaid",sjdaid);
bundle.putString("Name",strkmbh);
bundle.putString("ym",ym.toString());
intent.putExtras(bundle);
startActivity(intent);
Log.i(TAG, "向左");
Log.i(TAG, ym.toString());
} else if (moveX - pressX < 0 && Math.abs(moveY - pressY) < 50) {
ym=ym+1;
Intent intent = new Intent(BookContent.this, BookContent.class);
Bundle bundle = new Bundle();
bundle.putString("sjdaid",sjdaid);
bundle.putString("Name",strkmbh);
bundle.putString("ym",ym.toString());
intent.putExtras(bundle);
startActivity(intent);
Log.i(TAG, "向右");
}
break;
default:
break;
}
return true;
}
});