androidscrollzoomingtouchimageview

TouchImageView is not scrolling inside ScrollView


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"/>

Solution

  • 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>