Gesture Swipe in Android
Web Technologies
Web Development
2 years ago
5
Star Rating
1
Rating
_x000D_
_x000D_
I am working on a app where in i have a basic activity,When i swipe from left to right i need i need to get a swipe window which will display few icons,when i click from right to left i need to get an swipe window from right to left...i researched a bit...nd found few options like navigation drawer and swipe window and view pager....but swipe gesture jst swipes continuously from one page to another...i dont want that...i need to display few icons when i swipe from left to right and right to left....but i don't know exactly which one to use for better navigation....
i used the following code:
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
String swipe = "";
float sensitvity = 50;
// TODO Auto-generated method stub
if((e1.getX() - e2.getX()) > sensitvity){
swipe += "Swipe Left\n";
SwipeLeft();
}else if((e2.getX() - e1.getX()) > sensitvity){
swipe += "Swipe Right\n";
}else{
swipe += "\n";
}
if((e1.getY() - e2.getY()) > sensitvity){
swipe += "Swipe Up\n";
}else if((e2.getY() - e1.getY()) > sensitvity){
swipe += "Swipe Down\n";
}else{
swipe += "\n";
}
gestureEvent.setText(swipe);
return super.onFling(e1, e2, velocityX, velocityY);
}
};
I am confused on wthr i should use swipe of view pager..
this is something what i want..
Help appreciated.
Thanks.
Posted on 16 Aug 2022, this text provides information on Web Development related to Web Technologies. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Take Quiz To Earn Credits!
Turn Your Knowledge into Earnings.