
怎样控制android中gallery控件滑动时的速度
1个回答
展开全部
你好,方法如下:
public class MyGallery extends Gallery {
public MyGallery(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
public MyGallery(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public MyGallery(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
/**
* ①点下去的事件
* ②当前的事件
* ③滑动的x方向速度
* ④y方向的速度
*/
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
Log.v("velocityX========="+velocityX, "velocityY ===="+velocityY);
velocityX = velocityX>0 ? 400 : -400;
return super.onFling(e1, e2, velocityX, velocityY);
}
}
转载,仅供参考。
public class MyGallery extends Gallery {
public MyGallery(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
public MyGallery(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public MyGallery(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
/**
* ①点下去的事件
* ②当前的事件
* ③滑动的x方向速度
* ④y方向的速度
*/
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
Log.v("velocityX========="+velocityX, "velocityY ===="+velocityY);
velocityX = velocityX>0 ? 400 : -400;
return super.onFling(e1, e2, velocityX, velocityY);
}
}
转载,仅供参考。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询