3

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?

1 Answer 1

3

In method pageFlip change return true; to return false;

Sign up to request clarification or add additional context in comments.

1 Comment

@choop, so now you can continue to develop, awesome! :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.