0

I have multiple recyclerview inside Parent scrollview

In First Horizontal recyclerview there is one imageview, On touch event there is Image magnifier class called,

What i want to do is, When Imageview onTouch event called, I want to disable parent scollview.

I have tried custom linearlayout and tried also nested scroll enable false , but it didn't worked, because parent scrollview ontouch and imageview onTouch fired differently , both collides at same time.

Here my custom class code:

public class ImageMagnifier extends ImageView {
private PointF zoomPos;
private boolean zooming = false;
private Matrix matrix;
private Paint paint;
private Bitmap bitmap;
private BitmapShader shader;
private int sizeOfMagnifier = 200;

 public ImageMagnifier(Context context) {
    super(context);
    init();
}

public ImageMagnifier(Context context, AttributeSet attrs, int defStyleAttr) 
{
    super(context, attrs, defStyleAttr);
    init();
}

public ImageMagnifier(Context context, AttributeSet attrs) {
    super(context, attrs);
    init();
}

private void init() {
    zoomPos = new PointF(0, 0);
    matrix = new Matrix();
    paint = new Paint();

}

@Override
public boolean onTouchEvent(MotionEvent event) {
    int action = event.getAction();
    zoomPos.x = event.getX();
    zoomPos.y = event.getY();

        switch (action) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_MOVE:
                zooming = true;
                this.invalidate();
                break;
            case MotionEvent.ACTION_UP:
                break;
            case MotionEvent.ACTION_CANCEL:
                zooming = false;
                this.invalidate();
                break;

            default:
                break;
        }
    return true;
}

 @Override
protected void onDraw(Canvas canvas) {....} 
}

I am calling it from adapter xml :

<kalpcorporate.zimpia.all_library.ImageMagnifier
    android:id="@+id/img_productMangnifier"
    android:layout_width="match_parent"
    android:layout_height="@dimen/_200sdp"
    android:clickable="true"
    android:src="@drawable/main_product_pic_1" />

Thanks for help in advance.

Edit: I even tried recycler_view_product.addOnItemTouchListener but it is not calling anyway.

Shruti
  • 391
  • 1
  • 5
  • 21
  • Refer this answer : https://stackoverflow.com/questions/2537238/how-can-i-get-zoom-functionality-for-images – Nir Patel Apr 19 '18 at 06:31
  • @NirPatel, i dont want zoom functionality, and Magnifier functionality is working properly , Issue is with touch collision not with zoom or magnifier functionality. – Shruti Apr 19 '18 at 06:34
  • Try writing onTouch of scroll view and simply **return** initially. – Nir Patel Apr 19 '18 at 06:37

0 Answers0