Search code examples
androidandroid-volleynetworkimageview

Pinch and Zoom to network image view


Im using volley networkimageview to load images. Following is my layout file

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="#3dd2c6"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    <com.android.volley.toolbox.NetworkImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:id="@+id/zoomImg"/>
</LinearLayout>

Following is my code that I use to load images to NetworkImageView.

 NetworkImageView zoomImage = (NetworkImageView) findViewById(R.id.zoomImg);
SharedPreferences prefs = getApplicationContext().getSharedPreferences("private",
                PreferenceActivity.MODE_PRIVATE);
        String image = prefs.getString("imgUrl", null);
        zoomImage.setImageUrl(image, imageLoader);

How can i be able to set up pinch and zoom functionality to networkimageview?


Solution

  • I have created a custom image view with pinch & zoom plus network image view of volley. Please check at this link- https://gist.github.com/vkrm26/a21b5cca5d928485c4bc910a835e0003

    Let me know if any issue.