滚动视图缩放不左右滚动
Scrollview zoom not scrolling left and right
我正在尝试使 ScrollView 可缩放 post
mScaleDetector = new ScaleGestureDetector(context,
new ScaleGestureDetector.SimpleOnScaleGestureListener() {
@Override
public boolean onScale(ScaleGestureDetector detector) {
float scale = 1 - detector.getScaleFactor();
float prevScale = mScale;
mScale += scale;
if (mScale < 0.1f) // Minimum scale condition:
mScale = 0.1f;
if (mScale > 10f) // Maximum scale condition:
mScale = 10f;
ScaleAnimation scaleAnimation = new ScaleAnimation(
1f / prevScale, 1f / mScale, 1f / prevScale,
1f / mScale, detector.getFocusX(),
detector.getFocusY());
scaleAnimation.setDuration(0);
scaleAnimation.setFillAfter(true);
startAnimation(scaleAnimation);
return true;
}
});
但是缩放滚动只能上下滚动,我正在尝试让它也左右滚动。
Scrollview 只做垂直滚动,而 HorizontalScrollView 做水平滚动。
否 class (AFAIK) 启用双轴滚动,您可以在互联网上找到 classes 或自己编写。
我正在尝试使 ScrollView 可缩放 post
mScaleDetector = new ScaleGestureDetector(context,
new ScaleGestureDetector.SimpleOnScaleGestureListener() {
@Override
public boolean onScale(ScaleGestureDetector detector) {
float scale = 1 - detector.getScaleFactor();
float prevScale = mScale;
mScale += scale;
if (mScale < 0.1f) // Minimum scale condition:
mScale = 0.1f;
if (mScale > 10f) // Maximum scale condition:
mScale = 10f;
ScaleAnimation scaleAnimation = new ScaleAnimation(
1f / prevScale, 1f / mScale, 1f / prevScale,
1f / mScale, detector.getFocusX(),
detector.getFocusY());
scaleAnimation.setDuration(0);
scaleAnimation.setFillAfter(true);
startAnimation(scaleAnimation);
return true;
}
});
但是缩放滚动只能上下滚动,我正在尝试让它也左右滚动。
Scrollview 只做垂直滚动,而 HorizontalScrollView 做水平滚动。
否 class (AFAIK) 启用双轴滚动,您可以在互联网上找到 classes 或自己编写。