在android中左右滑动imageview

时间:2015-09-18 10:34:28

标签: swipe

我在屏幕中央有Imageview。

我想在屏幕的左右两侧滑动Imageview。我该如何实现?

2 个答案:

答案 0 :(得分:1)

查看https://github.com/nadavfima/GlowPadView

它具有glowpadview的开源实现。

您可以将其用作参考,并根据需要更改图标。它应该创建可转换的视图。

答案 1 :(得分:0)

我也在寻找一些非常简单的解决方案。我只需要左/右滑动。我找到了许多过于复杂的解决方案。所以我尽可能地减少了我发现的东西并提出了一些非常简单的东西(在这个例子中,滑动将在ID mainarea的div上工作,滑动被检测到至少100px到任何一侧):

var swipe={
 startx:0,touch:function(event) {
 if (typeof event.touches!=='undefined') {
   switch (event.type) {
    case 'touchstart':swipe.startx=event.touches[0].pageX;
    case 'touchend':
     if(Math.abs(swipe.startx-event.changedTouches[0].pageX)>100)
      swipe.startx<event.changedTouches[0].pageX?window.location.href=swipe.prev:window.location.href=swipe.next
   }
  }
 },init:function(prev,next){
  swipe.prev=prev;
  swipe.next=next;
  document.getElementById("mainarea").addEventListener('touchstart',swipe.touch,false);
  document.getElementById("mainarea").addEventListener('touchend',swipe.touch,false);
 }
}
swipe.init(<previous page>,<next page>);
相关问题