Android 在活动之间切换时,如何使页面像动画一样翻转?

Android 在活动之间切换时,如何使页面像动画一样翻转?,android,android-animation,Android,Android Animation,当从一个活动移动到另一个活动时,如何使页面像动画一样翻转?在一些ios应用程序上我看到了这一点,但当我搜索android时,我找不到任何关于这一点的教程或代码片段 请帮助Android上不存在活动的翻转动画。抱歉 以下是sdk的演示代码: /** * <p>Example of using a custom animation when transitioning between activities.</p> */ public class Animation ex

当从一个活动移动到另一个活动时,如何使页面像动画一样翻转?在一些ios应用程序上我看到了这一点,但当我搜索android时,我找不到任何关于这一点的教程或代码片段


请帮助

Android上不存在活动的翻转动画。抱歉

以下是sdk的演示代码:

/**
 * <p>Example of using a custom animation when transitioning between activities.</p>
 */
public class Animation extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_animation);

        // Watch for button clicks.
        Button button = (Button)findViewById(R.id.fade_animation);
        button.setOnClickListener(mFadeListener);
        button = (Button)findViewById(R.id.zoom_animation);
        button.setOnClickListener(mZoomListener);
    }

    private OnClickListener mFadeListener = new OnClickListener() {
        public void onClick(View v) {
            // Request the next activity transition (here starting a new one).
            startActivity(new Intent(Animation.this, Controls1.class));
            // Supply a custom animation.  This one will just fade the new
            // activity on top.  Note that we need to also supply an animation
            // (here just doing nothing for the same amount of time) for the
            // old activity to prevent it from going away too soon.
            overridePendingTransition(R.anim.fade, R.anim.hold);
        }
    };

    private OnClickListener mZoomListener = new OnClickListener() {
        public void onClick(View v) {
            // Request the next activity transition (here starting a new one).
            startActivity(new Intent(Animation.this, Controls1.class));
            // This is a more complicated animation, involving transformations
            // on both this (exit) and the new (enter) activity.  Note how for
            // the duration of the animation we force the exiting activity
            // to be Z-ordered on top (even though it really isn't) to achieve
            // the effect we want.
            overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
        }
    };
}
/**
*在活动之间转换时使用自定义动画的示例

*/ 公共类动画扩展活动{ @凌驾 创建时受保护的void(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_动画); //注意按钮的点击。 按钮按钮=(按钮)findViewById(R.id.fade\u动画); setOnClickListener(mFadeListener); 按钮=(按钮)findViewById(R.id.zoom\u动画); 按钮。setOnClickListener(mZoomListener); } 私有OnClickListener mFadeListener=新OnClickListener(){ 公共void onClick(视图v){ //请求下一个活动转换(此处开始新的活动转换)。 startActivity(新意图(Animation.this,Controls1.class)); //提供自定义动画。此动画只会使新动画褪色 注意,我们还需要提供动画。 //(这里只是在同样的时间里什么也不做)为了 //防止它过早消失的旧活动。 覆盖过渡(R.anim.fade,R.anim.hold); } }; 私有OnClickListener mZoomListener=新OnClickListener(){ 公共void onClick(视图v){ //请求下一个活动转换(此处开始新的活动转换)。 startActivity(新意图(Animation.this,Controls1.class)); //这是一个更复杂的动画,涉及变换 //在此(退出)和新(输入)活动中。注意 //我们强制退出活动的动画持续时间 //在顶部按Z顺序排列(即使实际上不是)以实现 //我们想要的效果。 覆盖渐变(R.anim.zoom\u进入,R.anim.zoom\u退出); } }; }

所有代码都在apidemo/app/,:)

是的,这是可能的。请看这个


下面是一个关于如何在两个活动之间过渡时添加动画的示例。但是,与本文中使用的平移动画不同,您需要使用旋转动画。

使用您发布的代码后的动画是“屏幕闪烁约0.25秒,并显示所调用的活动”,它与旋转或翻转完全不同:(我将持续时间从“300”更改为“3000”只是为了清楚地检查实际的动画。当我点击按钮从ActivityA转到ActivityB时,屏幕变黑,然后ActivityA慢慢出现,ActivityB出现。你能提供你刚才说的apidemo/app/的链接吗