安卓:ViewFlipper动画 [英] Android:ViewFlipper animation
问题描述
我有加,其中有2个的LinearLayout一个ViewFlipper,我已经作出了动画的xml:
left_in.xml:
I have add a ViewFlipper in which has 2 linearlayout,and I have made an animation xml: left_in.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="3000"/>
</set>
right_out.xml:
right_out.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="100%p" android:duration="3000"/>
</set>
left_out.xml:
left_out.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="-100%p" android:duration="3000"/>
</set>
right_in.xml:
right_in.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="3000"/>
</set>
在一个LinearLayout中的下一步按钮,显示了当第一次加载应用程序:
the "Next" button in one linearlayout which shows when first load the app:
mNext.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
mViewFlipper = (ViewFlipper)findViewById(R.id.viewFlipper1);
//mViewFlipper.setAnimation(AnimationUtils.loadAnimation(v.getContext(), R.anim.left_in));
mViewFlipper.setInAnimation(AnimationUtils.loadAnimation(v.getContext(), R.anim.left_in));
mViewFlipper.setOutAnimation(AnimationUtils.loadAnimation(v.getContext(), R.anim.right_out));
mViewFlipper.showNext();
}
});
和preV按钮:
and the "Prev" button:
mPrev.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
mViewFlipper = (ViewFlipper)findViewById(R.id.viewFlipper1);
mViewFlipper.setOutAnimation(AnimationUtils.loadAnimation(v.getContext(), R.anim.right_in));
mViewFlipper.setInAnimation(AnimationUtils.loadAnimation(v.getContext(), R.anim.left_out));
mViewFlipper.showPrevious();
}
});
下一步按钮顺利,但preV按钮去怪:当我点击了preV,它首先改变到previous视图,然后启动动画, ,最后它变成了previous观点了!如何解决呢?
在此先感谢!
The "Next" Button goes well, But the "Prev" Button goes strange: when I click the "prev",it first change into the previous view and then start the animation ,and at last it changes into the Previous view again! How to solve it?? Thanks in advance!!
推荐答案
您想要使用<一个href=\"http://developer.android.com/reference/android/widget/ViewAnimator.html#setOutAnimation%28android.view.animation.Animation%29\"相对=nofollow> setOutAnimation()
和<一个href=\"http://developer.android.com/reference/android/widget/ViewAnimator.html#setInAnimation%28android.view.animation.Animation%29\"相对=nofollow> setInAnimation()
。
You want to use setOutAnimation()
and setInAnimation()
.
这篇关于安卓:ViewFlipper动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!