简体   繁体   English

如何在viewpager中为片段设置动画?

[英]How can I animate a Fragment inside a viewpager?

I have got a viewpager that hosts two Fragments. 我有一个托管两个碎片的viewpager。 Now I would like to replace one of the Fragments on a button click. 现在我想在按钮点击上替换其中一个片段。 How can I animate this replacement? 我该如何为这个替代品制作动画? (eg using the flip-card effect) (例如使用翻盖卡效果)

Since it is difficult two put all my code in here, this is what I basically use http://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html 由于很难将两个代码放在这里,这就是我基本上使用的http://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html

You can animate it using a PageTransformer 您可以使用PageTransformer为其设置动画

Or, if you want the animation on replacing a fragment, you can set a custom animation on the FragmentTransaction 或者,如果您希望动画替换片段,则可以在FragmentTransaction设置自定义动画

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM