`
isiqi
  • 浏览: 16087787 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

APIDEMO ACTIVITY 过场动画

阅读更多

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);

API Level 5

Call immediately after one of the flavors of startActivity(Intent) or finish() to specify an explicit transition animation to perform next.

Parameters
enterAnim exitAnim
A resource ID of the animation resource to use for the incoming activity. Use 0 for no animation.
A resource ID of the animation resource to use for the outgoing activity. Use 0 for no animation.

}
};

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);
}
};
}

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@android:integer/config_longAnimTime" />

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator">
<scale android:fromXScale="2.0" android:toXScale="1.0"
android:fromYScale="2.0" android:toYScale="1.0"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="@android:integer/config_mediumAnimTime" />
</set>

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"
android:zAdjustment="top">
<scale android:fromXScale="1.0" android:toXScale=".5"
android:fromYScale="1.0" android:toYScale=".5"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="1.0" android:toAlpha="0"
android:duration="@android:integer/config_mediumAnimTime"/>
</set>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics