我在一个需要stackview的应用程序中.但是我必须实现水平滑动以在stackview项和UI外观之间切换为正常的.请帮我搞定.
我已经检查了这个link.
但在它中UI只是一个封面流程.我想让UI看起来像stackview一样.
最佳答案
我创建了一个自定义堆栈视图
原文链接:https://www.f2er.com/android/430981.html public class custom_stackview extends StackView{
float x1,x2,y1,y2,dx,dy;
public custom_stackview(Context context,AttributeSet attrs) {
super(context,attrs);
// TODO Auto-generated constructor stub
}
public custom_stackview(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
super.onTouchEvent(event);
switch(event.getAction()) {
case(MotionEvent.ACTION_DOWN):
x1 = event.getX();
y1 = event.getY();
break;
case(MotionEvent.ACTION_MOVE):
case(MotionEvent.ACTION_UP) :{
x2 = event.getX();
y2 = event.getY();
dx = x2 - x1;
dy = y2 - y1;
// Use dx and dy to determine the direction
if (Math.abs(dx) > Math.abs(dy)) {
if (dx > 0) {// direction = "right";
showNext();
} else {
showPrevIoUs();
}
}
}
// Log.v("hiiiiiiiiiii",direction+re);
}
return true;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
// TODO Auto-generated method stubLog.v("hiiiiiiiiiii","touched");
Log.v("hiiiiiiiiiii","toucheddddddddd");
//boolean re =false;
return false;
}
}
用于