1

从一个活动移动到另一个活动时,如何制作类似动画的翻页?在一些 ios 应用程序上,我看到了这个,但是当我搜索 android 时,我找不到任何教程或代码片段。

请帮忙

4

3 回答 3

2

对的,这是可能的 。请看这个教程

这是一个关于如何在两个活动之间转换时添加动画的教程。但是,您需要使用旋转动画,而不是像文章中那样使用平移动画。

于 2012-07-27T12:51:23.033 回答
0

ActivityAndroid 上不存在的翻转动画……抱歉!

于 2012-07-27T12:43:24.293 回答
0

这是来自 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);
        }
    };
}

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

于 2012-07-27T12:51:17.570 回答