本文介绍了滑出动画在后退按钮上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在进入或退出活动时使用动画,进入活动动画效果很好,但退出动画效果不佳.当我按下后退按钮时,我开始退出动画.会发生什么是首先开始为当前活动输入动画,然后显示最后一个活动,我想要一个简单的后退按钮退出动画.
I am using animations when entering or exiting the activity,entering to an activity animation works fine but exit animation does not work well. I start exit animation when i press back button.What happens is it first start enter animation for current activity then show the last activity what i want a simple exit animation on back button press.
Slide_out.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="0%p"
android:toXDelta="-100%p" >
</translate>
Slide_in.xml
Slide_in.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="100%p"
android:toXDelta="0%p" >
</translate>
在操作栏后退按钮被按下
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.home:
finish();
overridePendingTransition(R.anim.slide_out, R.anim.slide_in);
return true;
default:
break;
}
return super.onOptionsItemSelected(item);
}
推荐答案
我用过幻灯片_in.xml
I usedslide_in.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="100%"
android:toXDelta="0%" >
</translate>
slide_out.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="0%"
android:toXDelta="-100%" >
</translate>
slide_enter.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="-100%"
android:toXDelta="0%" >
</translate>
slide_exit.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="0%"
android:toXDelta="100%" >
</translate>
代码
Intent i=new Intent(Authentication.this,Login.class);
startActivity(i);
overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
上一个
finish();
overridePendingTransition(R.anim.slide_enter, R.anim.slide_exit);
这篇关于滑出动画在后退按钮上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!