所以我知道你可以使用overidePendingTransition方法在活动之间使用你自己的动画.我在两个活动之间设置了一个转换,它在我的模拟器上工作得很好但是当我将应用程序刷到我的手机上时,我看不到转换.怎么会这样?
我的模拟器和我的手机一样运行2.2
这是我的onCreate方法
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final Button button = (Button) findViewById(R.id.close); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent myIntent = new Intent(ActivityTransitionActivity.this,ActivityTwo.class); ActivityTransitionActivity.this.startActivity(myIntent); overridePendingTransition(R.anim.fadein,R.anim.fadeout); } }); }
解决方法
在style.xml中定义动画
<style name="Animation.CustomAnimation"> <item name="android:activityOpenEnterAnimation">@anim/slide_in_left</item> When opening a new activity,this is the animation that is run on the next activity <item name="android:activityOpenExitAnimation">@anim/slide_out_right</item>When opening a new activity,this is the animation that is run on the prevIoUs activity (which is exiting the screen) <item name="android:activityCloseEnterAnimation">@anim/slide_in_right</item>When closing the current activity,this is the animation that is run on the next activity (which is entering the screen). <item name="android:activityCloseExitAnimation">@anim/slide_out_left</item>When closing the current activity,this is the animation that is run on the current activity (which is exiting the screen). </style> <style parent="android:style/Theme.Light.NoTitleBar.Fullscreen" name="app_theme"> <item name="android:windowBackground">@drawable/splash</item> <item name="android:windowAnimationStyle">@style/Animation.CustomAnimation</item> </style>
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/app_theme">
将app_theme应用于Android清单中的应用程序