I think you need to use ViewFlipper instead of scrollView. use the touch event on the viewflipper to navigate and use the animation to scroll through two linear layouts.
this example will help you View a Flipper example
Edited by:
actions:
- there is a ViewFlipper that contains layout1, layout2, layoout3
- Currently displaying layout1.
- fling from right to left to display the next layout. layout1 β layout2
animation will be applied here in both views (layout1 and layout2).
for layout2 -> push_right_in.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator"> <translate android:fromXDelta="100%" android:toXDelta="0%" android:duration="400" /> </set>
for layout1 -> push_right_out.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator"> <translate android:fromXDelta="0%" android:toXDelta="-100%" android:duration="400" /> </set>
then set this animation to childflift.
flipper.setInAnimation(<your class>.this, R.anim.push_right_in); flipper.setOutAnimation(<your class>.this, R.anim.push_right_out); flipper.showNext();
- now goes from left to right to display the previous layout. layout2 β layout1
animation will be applied here in both views (layout1 and layout2).
for layout1 -> push_left_in.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator"> <translate android:fromXDelta="-100%" android:toXDelta="0%" android:duration="400" /> </set>
for layout2 -> push_left_out.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator"> <translate android:fromXDelta="0%" android:toXDelta="100%" android:duration="400" /> </set>
then set this animation to childflift.
flipper.setInAnimation(<your class>.this, R.anim.push_left_in); flipper.setOutAnimation(<your class>.this, R.anim.push_left_out); flipper.showPrevious();
This will give you smooth animation.
source share