开发者

How to use a sliding transition with Compatibility Library v4 Fragment Transactions

All I want is to be able to use FragmentTransaction.replace(...) and have fragments slide into and out of place just like activities, using the default activity animation.

By default the fragments simply appear and disappear. That is an acceptable default behavior.

With FragmentTransaction.setTransition(...) I can get Fragments to fade with a slight zooming animation. That is pretty cool, but it looks nothing like what activities do.

With FragmentTransaction.setCustomAnimation(...) a clusterfuck of things happen, and it looks ugly as hell.

And now I'm out of options. All I want to do is to have fragments slide left as I push to the stack, and have fragments slide right as I pop from the stack. Anybody know h开发者_StackOverflowow to do this short of implementing my own FragmentManager?


I have somewhat gotten around the problem by placing all of my fragments into a ViewPager. I can then setCurrentItem() to scroll between fragments. It's not pretty, and it takes a fair bit of manual effort, but it runs nice and quickly.

If there are any answers that aren't as hackish as what I've done, I'll definitely accept them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜