gpt4 book ai didi

android - 在 Android Activity 之间运行自定义动画

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:31:22 25 4
gpt4 key购买 nike

所以我知道您可以使用 overidePendingTransition 方法在 Activity 之间使用自己的动画。我在两个 Activity 之间设置了一个过渡,它在我的模拟器上运行完美,但是当我将应用程序刷写到我的手机上时,我看不到任何过渡。怎么会这样?

我的模拟器和我的手机一样运行 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 manifest 中的应用程序

关于android - 在 Android Activity 之间运行自定义动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7200267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com