我正在使用VerticalViewPager和TouchImageView进行图像放大/缩小。当我放大图像并尝试向下拖动图像(以查看图像的底部)时,视图寻呼机滑动到第二个图像。任何帮助将不胜感激。我需要禁用 viewpager 我试图更改垂直视图寻呼机的 canScroll 功能,但它没有帮助。
这是我修改的代码:
protected boolean canScroll(View v, boolean checkV, int dy, int x, int y) {
if(v instanceof TouchImageView)
{
Log.d("Here","Here");
if(((TouchImageView) v).getCurrentZoom()!=1)
{
Log.d("Here","HereAgain");
return false;
}
}
else if (v instanceof ViewGroup) {
final ViewGroup group = (ViewGroup) v;
final int scrollX = v.getScrollX();
final int scrollY = v.getScrollY();
final int count = group.getChildCount();
// Count backwards - let topmost views consume scroll distance first.
for (int i = count - 1; i >= 0; i--) {
// TODO: Add versioned support here for transformed views.
// This will not work for transformed views in Honeycomb+
final View child = group.getChildAt(i);
if (y + scrollY >= child.getTop() && y + scrollY < child.getBottom() &&
x + scrollX >= child.getLeft() && x + scrollX < child.getRight() &&
canScroll(child, true, dy, x + scrollX - child.getLeft(),
y + scrollY - child.getTop())) {
return true;
}
}
return checkV && ViewCompat.canScrollVertically(v, -dy);
}
return false;
}