I have a ScrollView and a very long text on TextView and I want to drag to the next/previous text according to the user action like that:
On my xml:
<ScrollView android:id="@+id/scrollViewTest" android:layout_height="wrap_content" android:layout_width="wrap_content"> <TextView android:id="@+id/textViewTest" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="very long text" /> </ScrollView> On the onCreate I implemented the OnTouchListener in order to drag to the next text.
ScrollView sv = (ScrollView) findViewById(R.id.scrollViewTest); sv.setOnTouchListener(new MyOnTouch()); The OnTouchListener define like that:
public class MyOnTouch implements OnTouchListener { @Override public boolean onTouch(View v, MotionEvent event) { return pageFlip(v, event); } public boolean pageFlip(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: startX = event.getX(); break; case MotionEvent.ACTION_UP: float currentX = event.getX(); if (startX > currentX + 150 ) { nextText(v); } if (startX < currentX - 150) { previousText(v); } default: break; } return true; } } The problem is when I'm implement it like that I can get to the next/previous text but I can't scroll up and down in order to see the text in the bottom.
Any suggestions?