I was looking for an animation to use for my view flipper and found this awesome page transformer animation on the Android Training page:
http://developer.android.com/training/animation/screen-slide.html
However, this is implemented using a ViewPager.PageTransformer and I'm using the newer ViewFlipper in my code. Has anyone figured out how to create such an animation using the ViewFlipper and ObjectAnimators? Just to explain what I've done so far:
I have an AdapterViewFlipper that gets populated with Fragments depending on user interactions.
The user can "flip" through these fragments by swiping on the ViewFlipper. This is done using a GestureDetector (OnGestureListener).
The onFling method defines the animation for the ViewFlipper
The last point is where I need to define the animation and this is where I'm lost.
Any ideas or help?!
Related
In Android (22+), I'm looking for a library or a 'tried & tested approach' to give the setup that allows an app to overlay 1 fragment on top of another that and would also provide gesture drag in/out along with peeking behind(see animation below)?
Criteria;
library to animate the swipe-in/out
handles the darkening the background fragment the further you drag in
the overlay fragment is there to provide context information to the user)
Further to #Rainmakers suggestions, I have a 'nearly working' approach were that I have an overlay fragment that is added to the top of the fragment stack; were then I have applied a touch gesture on the overlay fragment to dismiss on a left->right swipe capture. This Works and looks ok and 'will do' but would like the peek behind the feature that is shown in the animated GIF.
This animation was taken from the google drive android app;
If you're eager to use a library then check this out FragmentTransactionExtended. It has different slides.
Then you just override the onTouchEvent() method (check how to do it link) and do fragment transactions when swipe is caught. If you use add in the transaction you won't dispose the fragment underneath.
And the part with darkening you should also manage it in onTouchEvent(). See this to make your fragment grey out.
I'm looking for a way how to implement different slide animations for ViewPager for different slide directions. Of course we can implement ViewPager.PageTransformer and set it for ViewPager instance, but it will be the same animation for right and left slide directions.
Currently I see only one way to implement what I want. We can extend standard ViewPager and override onPageScrolled() method, and customize animations inside this method through getting left and right views and setting transformation parameters for them. But may be somebody knows how to do that in simpler(another) way?
I want to add flipping animation for viewpager, I am able to swipe the views but I also need to flip the view.
Any pointer?
Use JazzyViewPager instead of the regular ViewPager. You get a lot of cool built-in animations including flip animation.
You can also just go through the source and implement your flip animation using a PageTransformer.
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.
Android News & Weather app lets you swipe to reveal another view, just like the iPhone. Can someone show me an example of how this is done?
It is not a ViewFlipper attached to a GestureDetector.
It is a custom view, you can see how it's done in Launcher by looking at Workspace.java in packages/apps/Launcher2 at android.git.kernel.org.
You can now do this out-of-the-box in the Android Compatibility library with a ViewPager: http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html?m=1
ViewPager slides between Fragments much the same way ListViews scroll up and down with views.
If you're not interested in scrolling the tabs, there's an example in the SDK that uses a TabHost (instead of making the tabs themselves scrollable left-to-right), but you need not use a TabHost. You could, if you wanted horizontally-scrolling tabs, use a HorizontalScrollView with some buttons in it.
For an approach that doesn't use the compatibility lib, or fragments, see here: https://github.com/olibye/AndroViews