0

I have view pager in the ScrollView which contain the TouchImageView, i want to zoom and scrolling image. it's not scrolling when i touch the ImageView. my code is look like below please help me guys!

<com.ui.widget.TouchImageView
 android:id="@+id/img_item"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:scaleType="centerCrop"
 android:src="@drawable/img_girl1"/>

2 Answers2

1

Use This CustomScrollview and place TouchyImageview inside it

  public class CustomView extends ScrollView { 

   @Override
   public boolean dispatchTouchEvent(MotionEvent ev){
    super.dispatchTouchEvent(ev);    
    return mScaleDetector.onTouchEvent(ev); 
    }

    private class ScaleListener extends
    ScaleGestureDetector.SimpleOnScaleGestureListener {

        @Override
        public boolean onScale(ScaleGestureDetector detector) {
            // Handle the scale..
            return true;
        }
   }
}

Try This Scollview Instead Of Widget Scrollview here i remove the override onInterceptTouchEvent and onTouchEvent methods of scrollview

Ajay Pandya
  • 2,417
  • 4
  • 29
  • 65
0

Your requirement is very delicate. As TouchImageView is a custom widget, it may not have been dealt with NestedScrollView. Use PhotoViewAttacher to your ImageView and see if this works.

Add this to dependency in the app gradle:

 dependencies {
  compile 'com.commit451:PhotoView:1.2.4'
}

In Java Class:

PhotoViewAttacher pAttacher;
pAttacher = new PhotoViewAttacher(Your_Image_View);
pAttacher.update();

And then Attach your ImageView inside the NestedScrollView:

<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

           //Add ImageView Here

     </android.support.v4.widget.NestedScrollView>
tahsinRupam
  • 6,325
  • 1
  • 18
  • 34