Am using custom animations in view pager and these animations works perfectly when swiping left or right,but when pressing on the tabs itself without swiping, the animations is done very fast causing damage to the eye, so is there any function to change the delay when pressing on the tabs ?
The first thing comes to my mind is making delay with a handler but delaying the transition between pages may cause unexpected result because of user behavior like clicking buttons very fast. I recommend making the view pager's transition animation a little slower. You can achieve such a behavior by using the Slowing speed of Viewpager controller in android
Related
I'm working on an Android app that uses a navigation drawer and multiple navigation menu items. Inflating the views and running onCreate() takes some time, which makes the drawer close animation very laggy. I'm already working on optimizing the fragment layout itself to reduce jank, but the animation is still laggy.
My quick fix was adding a drawer listener and calling getSupportFragmentManager().beginTransaction().replace(...).commit() on drawer close. However the problem with this is that the previous fragment still remains in the UI for a few milliseconds after the drawer is closed, which looks arguably worse than with the laggy animation.
How is it possible to ensure a smooth drawer close animation and concurrently load the new fragment - or is there another way to make the UI transitions look more natural?
I have the requirement for what is effectively two activities side by side, allowing the user to scroll from one to the other, and back. I've decided that ViewPager is probably the best way to handle this, but am open to suggestions.
When the activity loads, the left hand view is displayed. I want to indicate to the user that the other view exists, by just scrolling it a small amount to the left and back again (similar to the way it's now common to show that a sliding drawer menu exists).
I've tried a number of things but have yet failed to find a method where both the views scroll smoothly together. Another way of interpretting the requirement is saying I want to programmatically fake a user flicking the page briefly.
Try calling the method fakeDragBy(float)! According to the documentation you need to first call beginFakeDrag() to initiate it and then call endFakeDrag(). This will mantain the ViewPagers default snapping behavior, so once you've revealed the other screen is there you don't have to animate the transition back, simply call endFakeDrag and the ViewPager will correctly snap back to the last screen (As long as you haven't dragged it past the half-way mark).
I need to create a bottomnavigationmenu that hides like in that one link:
https://github.com/NikolaDespotoski/ahbottomnavigation
But instead of make it fade by scroll, fade with timer, like, 2 seconds of inactivity
Any hints? I don't know how to access the behavior of the scroll through my main activity
What I would like to achieve: Have a ViewPager with TabLayout where each Tab contains a new Fragment that has a RecyclerView layout out horizontally and managed by a FragmentPagerAdapter.
What I am struggling with: The default behaviour is that when you get end of the list on one of the tabs, it switches Tabs and snaps (snapping means if you pull over 50% of the viewport, it jumps to either direction). I want it to free-flow and not to snap. Sort of like how it happens in iOS by default.
I got inspired for this setup by the following two CodePath guide:
https://guides.codepath.com/android/google-play-style-tabs-using-tablayout
https://guides.codepath.com/android/ViewPager-with-FragmentPagerAdapter
How should I approach this problem (preferably without any other libraries)?
What I would do is use HorizontalScrollView instead of a ViewPager. The only caveat is that the view pager sends the lifecycle events to fragments as you scroll between them, whereas for HorizontalScrollView you will have to add them initially, and then they will be continuously active unless you manually change that. Also you may have an option to not use the fragments and use simple views depending on what you use the fragments for.
I would definitely not override the touch events for the ViewPager because it does some cleanup when it detects the UP motion, so just swallowing it is not a correct thing to do.
I've implemented webViews within a ViewPager, but instead of the default animation (as seen with Launcher), I want to have a sliding animation.
Let's say I have 2 webviews. If I flick to the right, the left webview moves out of view and to the left and eventually becomes non visible, then the right webview moves left and becomes fully visible. I need there to be an instant where nothing appears on the viewPager during the transition.
Is this easily done with viewPager or do I have to scrap it and work with Animations completely?
I have found a good source to do it with pure animation but it may be hard to implement for webviews: http://blog.stylingandroid.com/archives/137
Thanks in advance.
viewpager doesn't match to your needs I think. use ViewFlipper instead and you can custom in/out animations.