请看下面的代码,
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
if(viewPager.getCurrentItem()==1){
Log.d("MAIN_ACTIVITY", "POSITION " + position);
viewPager.setPageTransformer(true, new ViewPager.PageTransformer() {
@Override
public void transformPage(View page, float position) {
Animation logoMoveAnimation = AnimationUtils.loadAnimation(context,R.anim.logoanimation);
page.startAnimation(logoMoveAnimation);
}
});
}else{
viewPager.setPageTransformer(true, null);
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
logoanimation.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<scale android:fromXScale="0.0" android:fromYScale="0.0"
android:toXScale="1.0" android:toYScale="1.0"
android:duration="700" android:fillBefore="false" />
<translate android:fromXDelta="-200" android:fromYDelta="-200"
android:duration="700" />
</set>
当前动画淡出淡出。但我想从右到左动画放置viewpager的元素是向前还是向后移动。
有任何想法吗?
谢谢。