I am new in android development
. I am trying to make a wallpaper application where need to integrate images swipe and pinch zoom
functionality.
I had done both but not at a time. When I integrate swipe its work but when I integrate pinch zoom then not worked it. Both functionality work alone but not together.
I tried to find solutions many times but not get from any where. Below code used.
public class FullImageActivity extends Activity {
protected int curruntPosition;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_full_image);
ImageAdapter imageAdapter = new ImageAdapter(this);
List<ImageView> images = new ArrayList<ImageView>();
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
for (int i = 0; i < imageAdapter.getCount(); i++) {
ImageView imageView = new ImageView(this);
imageView.setImageResource(imageAdapter.mThumbIds[i]);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
images.add(imageView);
}
ImagePagerAdapter imagePagerAdapter = new ImagePagerAdapter(images);
viewPager.setAdapter(imagePagerAdapter);
int position = getIntent().getExtras().getInt("id");
viewPager.setCurrentItem(position);
viewPager.setOnPageChangeListener(new OnPageChangeListener() {
@Override public void onPageSelected(int arg0)
{ // TODOAuto-generated method stub // Here you can set the wallpaper
curruntPosition = arg0;
}
@Override public void onPageScrolled(int arg0, float arg1, int arg2)
{ // TODO Auto-generated method stub
}
@Override public void onPageScrollStateChanged(int arg0)
{ // TODO Auto-generated method stub
}
});
TouchImageView img = new TouchImageView(this);
img.setImageResource(imageAdapter.mThumbIds[position]);
img.setMaxZoom(4f);
setContentView(img);
}
}
}
I used above code. Let me know if any one have a solution what actually issue with it.
thanks
maybe you can try to avoid swiping when you have to pinch
After doing this, the only thing left was to substitute the ViewPager tag on the layout file for my own class and then call the method setPagingEnabled false, hope it helps