I need to make 2 screens with custom animation like explained below :
Screen 1 Screen 2 ----------------------------- ------------------------------ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | List 1 | List2 | ---------> | List 3 | List 4 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ----------------------------- ------------------------------
Is it possible to do this animation using ViewPager
? If yes, How?
I would like to do this via ViewPager
because I'm using Fragment
s pretty extensively and I have implemented many screens as fragments already.
If anyone needs clarification about the animation or the UI, please let me know.
Update : I was able to implement both of the screens in a single activity which I have partially explained here. I can implement the same in a single fragment. But being able to implement as different Fragment
s in a ViewPager
would still help.
ViewPager, too me, seems like overkill. Unless you want to add more screens later, or some other requirement. For these simple screens you can do it with ActivityAnimations. If you put Screen1 and Screen2 in a seperate Activity, you can animate the Activities using simple styles. You don't need to code, simply define the Enter and Exit styles for your activities, and they will be executed.
So, unless you have another reason for using the ViewPager, you can accomplish the same effect by the following (not tested):
Android Manifest.xml
<activity android:name=".Screen1" android:theme="@style/Animated"></activity>
<activity android:name=".Screen2"></activity>
Your themes.xml
<resources>
<style name="Animated">
<item name="android:windowAnimationStyle">@style/Animation.ScreenAnimation</item>
</style>
</resources>
Finally, in your styles.xml
<style name="Animation"></style>
<style name="Animation.ScreenAnimation" parent="android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">@anim/slide_in_right</item>
<item name="android:activityOpenExitAnimation">@anim/slide_out_left</item>
<item name="android:activityCloseEnterAnimation">@anim/slide_out_left</item>
<item name="android:activityCloseExitAnimation">@anim/slide_in_right</item>
</style>
I have successfully used vertical ListViews inside of ViewPagers before. How about trying a horizontal scrolling list view inside of your ViewPager?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With