I have a scrollview in which there are other views, and I can interact with one of these views (scroll left-right) (the view is self-written and the interaction is done using ontouchEvent), but if I move the finger up or down a little while scrolling to the left or right, then the focus on the view gets off and the scrollview starts to scroll, how can this be changed? After all, if the same scrollview of a different orientation is located in the scrollview, then there will be no problems.

    1 answer 1

    after several days of googling, I still found a solution: you need to call the requestDisallowInterceptTouchEvent (true) method; in OnTouchEvent of our View for the parent View. This method prohibits the OnTouchEvent method that the scrollView did to intercept with the entire parent View.

    setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: v.getParent().requestDisallowInterceptTouchEvent(true); //ваши действия break; case MotionEvent.ACTION_MOVE: //ваши действия break; case MotionEvent.ACTION_UP: //ваши действия break; } invalidate(); return true; } });