Tôi nghĩ bạn phải sử dụng ViewFlipper thay vì scrollView. sử dụng sự kiện chạm trên trình xem ảnh để điều hướng và sử dụng hoạt ảnh để lật hai Bố cục tuyến tính.
ví dụ này sẽ giúp bạn View Flipper example
được sửa đổi:
bước sau:
- có một ViewFlipper chứa layout1, layout2, layoout3
- hiện layout1 là nhìn thấy được.
- trượt từ phải sang trái để hiển thị bố cục tiếp theo. layout1 -> layout2
hoạt ảnh sẽ áp dụng ở đây trên cả hai chế độ xem (bố cục 1 và bố cục2).
cho 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>
cho 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>
sau đó thiết lập hình ảnh động này sang con viewflipper của.
flipper.setInAnimation(<your class>.this, R.anim.push_right_in);
flipper.setOutAnimation(<your class>.this, R.anim.push_right_out);
flipper.showNext();
- tại quăng ra từ trái sang phải cho thấy cách bố trí trước. layout2 -> layout1
các hình ảnh động sẽ được áp dụng ở đây trên cả hai quan điểm (layout1 và layout2).
cho 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>
cho 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>
sau đó thiết lập hình ảnh động này sang con viewflipper của.
flipper.setInAnimation(<your class>.this, R.anim.push_left_in);
flipper.setOutAnimation(<your class>.this, R.anim.push_left_out);
flipper.showPrevious();
này sẽ cung cấp cho bạn một hình ảnh động trơn tru.
Nguồn
2011-04-19 09:35:55
Xem hướng dẫn này. Nó được thực hiện với ViewFlipper http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/ –