I am new to android development. I am using photoview library to enable zooming of images in my imageviewer app. But viewpager and zooming ability are not working at the same time.When I include photoView.setVisibility(View.GONE);
in FullImageActivity.java, viewpager starts working and when I remove it, zooming ability starts working. But both zooming and viewpager do not work at the same time. How do I fix this ? Thanks
Full code is available at https://github.com/redviper00/game
FullImageActivity.java:
public class FullImageActivity extends AppCompatActivity {
int position;
int folderPosition;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_full_image);
Intent i = getIntent();
PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);
photoView.setVisibility(View.GONE);
// Selected image id
position = i.getExtras().getInt("id");
folderPosition = i.getExtras().getInt("folderPosition");
Bundle extras = getIntent().getExtras();
String value = extras.getString("abc");
Glide.with(FullImageActivity.this)
.load(value)
.skipMemoryCache(false)
.into(photoView);
ViewPager mViewPager = (ViewPager) findViewById(R.id.viewpager);
mViewPager.setAdapter(new TouchImageAdapter(this,al_images, folderPosition));
mViewPager.setCurrentItem(position);
}
}
activity_full_image.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/jazzy_pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/photo_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="centerCrop"/>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
You are not using Imageview inside your adapter eg : TouchImageAdapter. You should use PhotoView Object, and your issue will resolved.
PhotoView img = new PhotoView(container.getContext());
Please have a look at code changes which I pushed to your repository.