本来感觉是一个很小的需求, 后来发现老是 出问题, 使用Theme在 4.0上 操作不是很好用.
后来查阅资料, 需要在finish 后面 和 startActivity 后面添加
overridePendingTransition(R.anim.push_right_in,
R.anim.push_right_out);
这句话 但是每个地方都添加这个代码也很坑爹, 于是看了一下ECShop的实现,发现是在BaseActivity加入的..
@Override
public void startActivity(Intent intent) {
super.startActivity(intent);
overridePendingTransition(R.anim.push_right_in,
R.anim.push_right_out);
}
public void startActivityForResult(Intent intent, int requestCode)
{
super.startActivityForResult(intent,requestCode);
overridePendingTransition(R.anim.push_right_in,
R.anim.push_right_out);
}
@Override
public void finish() {
super.finish();
overridePendingTransition(R.anim.push_left_in,R.anim.push_left_out);
}
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%" android:toXDelta="0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:duration="300"/>
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="-100%"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:duration="300" />
</set>