Yes I too had the same problem not with TouchImageView.
Too solved the problem what i did is disabled the ViewPager when my view is getting the focus.
public class EnableDisableViewPager extends ViewPager {
private boolean enabled = true;
public EnableDisableViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
if(enabled)
return super.onInterceptTouchEvent(arg0);
return false;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}
so in TouchImageView implement your listener to trigger an event whether its zooming or dragging.
set listener to your view object in your Activity. So when those event occur just disable the view Pager.
Note: you will also need a mouse up event to enable the viewpager.
EDITED
This will work only for Zoom, so for ViewPager to swipe pages you should zoom back to original.
Add these code to your TouchImageView
public class TouchImageView extends ImageView {
...
private TouchEventListener touchEventListener;
private void sharedConstructing(Context context) {
...
setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
...
case MotionEvent.ACTION_UP:
...
if(touchEventListener != null)
{
if(saveScale == 1.0)
touchEventListener.onZoomToOriginal();
else
touchEventListener.onZoom();
}
break;
...
}
...
}
});
}
...
public TouchEventListener getTouchEventListener() {
return touchEventListener;
}
public void setTouchEventListener(TouchEventListener touchEventListener) {
this.touchEventListener = touchEventListener;
}
public interface TouchEventListener
{
void onZoom();
void onZoomToOriginal();
}
}
.
stackoverflow.comm
No comments:
Post a Comment