Two kinds of ontouchlistener of the same area as?

I have two ImageViews.

1.ImageView zoomImageMoveable: should zoom in, zoom out and move. 2.ImageView zoomImageFixed: show the scale, this is the guide line.

I want to run different functions with one click.

{
 FrameLayout myFrame = new FrameLayout(this.getContext());
     myFrame.addView(zoomImageMoveable);
     myFrame.addView(zoomImageFixed);
}

Case 1. I tried to connect a listener to each of the views, since they overlap only one file.

Case 2. I also tried to wrap two views using FrameLayout and added OnTouchListener to this layout so that it redirects calls to each of the assigned methods. However, this method also did not work.

 myFrame.setOnTouchListener(new OnTouchListener() {
      @Override
      public boolean onTouch(View v, MotionEvent event) {
           zoomImageMoveable.onTouchEvent(event);
           zoomImageFixed.onTouchEvent(event);
           return false;
      }
 });

How do I approach this problem?

+3
source share

Source: https://habr.com/ru/post/1782017/


All Articles