Comments (3)
是只要一滑动recyclerview就滑动,无论图片缩放如何,同问
from pinchimageview.
是只要一滑动recyclerview就滑动,无论图片缩放如何,同问
我的解决方案就是1.在PinchImageView 里面的添加一个boolean 参数控制是否需要放弃touch方法。
private boolean isInTouch = false;
public boolean isInTouchAction() {
return isInTouch;
}
public boolean onTouchEvent(MotionEvent event) {
....
if (action == MotionEvent.ACTION_DOWN) {
//在矩阵动画过程中不允许启动滚动模式
if (!(mScaleAnimator != null && mScaleAnimator.isRunning())) {
isInTouch = true;
}
}
....
}
private boolean scrollBy(float xDiff, float yDiff) {
if (!isReady()) {
SnbLog.e(">>>>>sssdf:false");
return false;
}
//原图方框
RectF bound = MathUtils.rectFTake();
getImageBound(bound);
//控件大小
float displayWidth = getWidth();
float displayHeight = getHeight();
//如果当前图片宽度小于控件宽度,则不能移动
if (bound.right - bound.left < displayWidth) {
xDiff = 0;
//如果图片左边在移动后超出控件左边
isInTouch = false;
} else if (bound.left + xDiff > 0) {
//如果在移动之前是没超出的,计算应该移动的距离
if (bound.left < 0) {
xDiff = -bound.left;
//否则无法移动
isInTouch = true;
} else {
xDiff = 0;
isInTouch = false;
}
//如果图片右边在移动后超出控件右边
} else if (bound.right + xDiff < displayWidth) {
//如果在移动之前是没超出的,计算应该移动的距离
if (bound.right > displayWidth) {
xDiff = displayWidth - bound.right;
isInTouch = true;
//否则无法移动
} else {
xDiff = 0;
isInTouch = false;
}
}
//以下同理
if (bound.bottom - bound.top < displayHeight) {
yDiff = 0;
} else if (bound.top + yDiff > 0) {
if (bound.top < 0) {
yDiff = -bound.top;
} else {
yDiff = 0;
}
} else if (bound.bottom + yDiff < displayHeight) {
if (bound.bottom > displayHeight) {
yDiff = displayHeight - bound.bottom;
} else {
yDiff = 0;
}
}
....
}
private void scaleEnd(){
//启动矩阵动画
mScaleAnimator = new ScaleAnimator(mOuterMatrix, animEnd);
mScaleAnimator.addListener(new Animator.AnimatorListener() {
,,,
@Override
public void onAnimationEnd(Animator animation) {
isInTouch = false;
}
....
});
}
2.在用到的LayoutManager 重写canScrollHorizontally()或canScrollVertically() 来控制recyclerview 能不能滑
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false) {
@Override
public boolean canScrollHorizontally() {
if (currentImageView != null) {
return !currentImageView.isInTouchAction();
}
return true;
}
};
上面的scrollBy只判断的左右的超出了之后的事情,如果recyclerview是上下滑需要把判断放大y方向上。
目前是这样解决的,双指的时候可能还有点问题,基本使用问题不大。
from pinchimageview.
我也不知道怎么引用回复,就直接发了。貌似这个库只是手势,并没有分块加载功能,作者的demo是手动实现的分块加载。貌似比较成熟的库还是ssiv
from pinchimageview.
Related Issues (20)
- 求助: 缩放 或 平移后 图片在原图的 x y 座标 还有 长宽
- 单击返回
- 请问怎么依赖 HOT 2
- 很赞,完美解决了我的问题
- 点击放大动画,页面图片怎么没正常显示,都是黑色块?
- 能否实现 ios 那样的拖出边界后的弹簧效果
- 图片缩放后得到imageview区域显示的图片
- addOuterMatrixChangedListener双击放大,再双击缩小得到的ImageBound不一样
- Glide拿不到监听回调
- 如何获取点击位置对应的图片位置
- 有没有禁止放大缩小的方法啊 HOT 1
- 请问如何禁止双指缩小后的图片大小回弹?
- 配合Glide使用
- PinchImageView加载长图(宽度屏幕长度/高度很小的图)会oom,Canvas: trying to draw too large(129709492bytes) bitmap HOT 1
- 如何支持gif图片?
- How to zoom simultaneously on two ImageViews?
- 加载宽高比为10及以上(或许更小)的图会报OOM
- 请问,up主怎么改造了viewpager HOT 3
- How can i integrate it for textureview ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pinchimageview.