I'd like to implement a view that when invisible, slides in when swiping from the right (from outside of the screen). When visible, slides back out to the right when swiping to the right from outside that view.
So I guess this is called a swipe gesture while showing the slide animation as the swipe is still being done. I want it to be fluent, which means that if the swipe gesture is only part made, the view will only part slide, meaning the view follows the gesture.
I'm thinking of something very similar to Amazon's Cloud Drive months view. See screenshot below.
Any idea how to do this? An Example code? 3rd party library?
I tried to search for this. Found how to do the animation: here and here. Found how to recognize the gestures: here and here. Found even the combination of both but not when swiping from the edge of the screen to open nor when swiping from outside of the view to close.
Here are the things I investigated that didn't do the job and why:
SlidingMenu - Slides from the edge and from outside of the view but animates the main window and not just the side view. Also, it's very complicated and hard to get only the required behavior of sliding from/to the edge.
Roman Nurik's Android-SwipeToDismiss - Doesn't recognize swiping from outside of the view nor from the edge of the screen.
Wunderlists - Doesn't recognize swiping from outside of the view nor from the edge of the screen.
Related
I want to flip a card view (show the different layout for front/back) using a swipe gesture (swiping from left to right).
Is there a way to achieve this? All examples that I managed to find are using click functionality (on a button, view that is being flipped, etc.) but not a swipe.
I have a horizontal slider in my app, and I want to make it so that if you have the slider selected, you can do the two-fingered swipe up or down gesture from anywhere on the screen (The scroll up or down gesture) to move the slider left or right. I haven't been able to find anything through google about how to change vertical swipe behavior for Talkback and was wondering if there was in fact a way to change this.
I'd really suggest not doing this, it isn't how Android works so it will confuse your users, and be a big source of bugs as any behavior like this can cause touch errors on completely separate views. I just fixed a problem on something similar in my company's app.
But if you really want to do this- your root ViewGroup needs to intercept touch events if there are two fingers down and it moves far enough to qualify. Read https://developer.android.com/training/gestures/viewgroup#intercept for an explanation of how a parent view group can steal touch events from the child. This is the same way ScrollView works to scroll its contents. In fact, looking up the AOSP implementation of ScrollView would give you good example code.
I am trying to control the scrolling behaviour of snap scroll flag of collpasingtoolbarlayout . According to this tutorial link
SCROLL_FLAG_SNAP: Upon a scroll ending, if the view is only partially visible then it will be snapped and scrolled to it's closest edge. what I'm trying to achieve is to make the Snap Behaviour works in 1 Direction only from Bottom to Top . which means if that view is close from the top edge and the user is scrolling from the bottom it should work normally in this cause. otherwise, for ex if user scrolling from top to bottom it should do nothing.
Here is a gif of Santa application of Google which I'm trying to achieve the same behaviour .
Gif Link
Here's a link to a post that was made before the support for the snap scroll flag which includes code that recreates the same behavior. You might be able to modify this custom behavior to fit your needs.
In that code you will find the following section which you need to edit for your "close to top or bottom" logic:
if (topOffset < -(scrollRange / 2f)) { //Close to top
// Snap up (to fully invisible)
animateOffsetTo(-scrollRange);
} else { //Close to bottom
// Snap down (to fully visible)
animateOffsetTo(0);
}
You will also need to include logic to compare the offset at the start of the scroll to the offset at the stop of teh scroll to determine the swipe direction.
Good luck!
I've a menu in Android app with several ImageButton (all grouped in a RelativeLayout) and I would like to make it disappear when swiping with finger towards the outside of the screen.
Swiping with finger towards the inside of the screen, instead, the menu should re-appear.
Any suggestion to do this ?
Try writing a gesture detection as given here Fling gesture detection on grid layout and in that code instead of toast write your code.
I've made an activity that looks a lot like the level select screen from angry birds: there is a grid of button, and you can scroll through pages of them by swiping right or left.
I built it by creating a layout of the buttons, and then adding those layout to a Gallery view.
The problem is the animation is jerky, even if you swipe extra slowly, the content jumps ahead. Even when you fling the gallery page, it skips and jumps along its way to its destination.
I am wondering how to fix this: Maybe the complex layout it making it non responsive during the inflate?
Do you know how to fix this, or of a good way to do a workaround using some other approach that will let me have 3 or more screens smoothly swiping from page to page?
You should be using ViewPager. This is available in android support packages. Gallery Widget will not be smooth if you add components into it which has a lot of touch actions.
http://android-developers.blogspot.in/2011/08/horizontal-view-swiping-with-viewpager.html