通过刷卡的下一步和previous图像 [英] next and previous image by swipe s
本文介绍了通过刷卡的下一步和previous图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Android和工作的一个漫画应用新的。
我用这code访问
https://github.com/sephiroth74/ImageViewZoom 以双指缩放。和工作非常精细。
i am new in android and working a comic application. i am using this code visit https://github.com/sephiroth74/ImageViewZoom for pinch zoom . and working it very fine.
但我试图通过刷卡进入下一步和previous形象。
但我不能。这是我的code这是按钮OK,现在我想添加刷卡方法。
but i am trying to go to next and previous image by swipe . but i am unable . this is my code which is OK for button and now i want to add swipe method .
next.setOnClickListener( new OnClickListener() {
public void onClick( View v ) {
selectnextImage();
}
} );
pre.setOnClickListener( new OnClickListener() {
public void onClick( View v ) {
selectpreImage();
}
} );
感谢ü
请哪位高手给我一点时间。
thank u please any expert give me a bit time .
推荐答案
您可以在您这样的主视图检测一扔手势
You can detect fling gestures on your main view like this:
final GestureDetector detector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if(velocityX > 0) {
selectnextImage();
}
else {
selectpreImage();
}
return true;
}
});
view.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getPointerCount() == 1) {
if(mimage.getScale() == 1f) {
detector.onTouchEvent(event);
return true;
}
else {
return false;
}
}
else {
return false;
}
}
});
这篇关于通过刷卡的下一步和previous图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文