Search code examples
androidandroid-scrollviewontouchlistener

How to detect touch event at ScrollView?


Before explaining, I don't want to use TouchEvent at Scrollview inner Scrollview.

I want to make when touching up the scrollView, make popup window. but to use onTouchEvent, isn't it only can detect ACTION_MOVE, UP, DOWN?

I used gesture detector.

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_read);

        ScrollView readScroll = (ScrollView)findViewById(R.id.readScrollView);
        TextView textView = (TextView)findViewById(R.id.TextView);
        String filePath = getIntent().getStringExtra("File_Path");

        textView.setText(readFile(filePath));

    }

    @Override
    public boolean onSingleTapUp(MotionEvent e) {
        Toast.makeText(ReadActivity.this, "onKeyUp", Toast.LENGTH_SHORT).show();
        return false;
    }

but it doesn't work. I think it is disabled because of scrollView.

How to detect touch event at scrollView?


Solution

  • As you've already mentioned in the question, onTouchEvent do have ACTION_UP that is meant to handle when touch up.