How to Photo Image -Pinch open and Pinch close in Android Native App automation

Hi Friends,

In my app automation ,there is new requirement to Pinch Open and close the photo image.Could you please any1 help me on this.

Steps:

  1. If Pinch In the Photo Preview image ,then will show in enlarged
  2. Then Pinch Close ,back to preview image

HI Jaga,
Please try this

WebElement Image = driver.findElementById(“com.davemorrissey.labs.subscaleview.sample:id/imageView”);

        Thread.sleep(5000);
        int x=Image.getLocation().getX()+Image.getSize().getWidth()/2;
        int y= Image.getLocation().getY()+Image.getSize().getHeight()/2;
                
        //Zoom out
        TouchAction finger1= new TouchAction(driver);
        finger1.press(Image, x, y-20).moveTo(Image,x,y-50);
        
        TouchAction finger2= new TouchAction(driver);
        finger2.press(Image, x, y+20).moveTo(Image, x, y+50);
        
        
        
        MultiTouchAction action= new MultiTouchAction(driver);
        action.add(finger1).add(finger2).perform();
        System.out.println("Zoom Done");
        Thread.sleep(10000);
        
        
        TouchAction finger3= new TouchAction(driver);
        finger3.press(Image, x, y-20).moveTo(Image, x, y-10);
        
        TouchAction finger4= new TouchAction(driver);
        finger4.press(Image, x, y+20).moveTo(Image, x, y+10);
        
        
        MultiTouchAction action2= new MultiTouchAction(driver);
        action2.add(finger3).add(finger4).perform();
        
        System.out.println("Pinch Done");
        Thread.sleep(10000);

Thanks Hari for Quick Respond.

I tired but its not working.

Hari -could you have any other solution?Plz share