从一个活动移动到另一个活动时,如何制作类似动画的翻页?在一些 ios 应用程序上,我看到了这个,但是当我搜索 android 时,我找不到任何教程或代码片段。
请帮忙
从一个活动移动到另一个活动时,如何制作类似动画的翻页?在一些 ios 应用程序上,我看到了这个,但是当我搜索 android 时,我找不到任何教程或代码片段。
请帮忙
Activity
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);
}
};
}
所有代码都在 apidemo/app/ ,:)