首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

Gallery 撤消惯性滚动 & 实现短距离滚动

2012-09-14 
Gallery 取消惯性滚动 & 实现短距离滚动Gallery 组件的特点:惯性滚动 与 半屏翻页。?取消惯性滚动 与 实现

Gallery 取消惯性滚动 & 实现短距离滚动

Gallery 组件的特点:惯性滚动 与 半屏翻页。

?

取消惯性滚动 与 实现短距离滚动:

?

public class DetialGallery extends Gallery {  public DetialGallery(Context context, AttributeSet attrSet) {   // TODO Auto-generated constructor stub   super(context, attrSet);  }  @Override  public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,    float velocityY) {   // TODO Auto-generated method stub   // 只需要去除翻页惯性 - 方法1:   // return super.onFling(e1, e2, 0, velocityY);   // 只需要去除翻页惯性 - 方法2:   // return false;   // 实现短距离滚动:   int kEvent;   if (isScrollingLeft(e1, e2)) {    // Check if scrolling left    kEvent = KeyEvent.KEYCODE_DPAD_LEFT;   } else {    // Otherwise scrolling right    kEvent = KeyEvent.KEYCODE_DPAD_RIGHT;   }   onKeyDown(kEvent, null);   return true;  }  private boolean isScrollingLeft(MotionEvent e1, MotionEvent e2) {   return e2.getX() > e1.getX();  } }

?

热点排行