假如果是Activity1启动Activity2:即在Activity中startActivity(//Activity2);而现在我要让Activity1慢慢消失,Activity2慢慢出现,而不是系统默认的直接出现来到前台。
在网上有人说在startActivity()之后加上overridePendingTransition(enterAnim, exitAnim)方法,但我都试了好多遍,还是不行。求大师讲解?????????????
在网上有人说在startActivity()之后加上overridePendingTransition(enterAnim, exitAnim)方法,但我都试了好多遍,还是不行。求大师讲解?????????????
解决方案 »
- 为什么进入android 4.0.3模拟器的时候,会出现错误?请帮忙?
- android上有PropertyUtils的替代品吗?
- 会java准备学android游戏开发,帮忙推存几本android书籍
- 有没做移植开发的 能给找个串口测试的程序吗
- android工程中只能有一个strings文件吗
- android 多条通知
- 求助,Arm板移植Android系统
- 为什么将网络访问放到另一个线程之后还是出现android.os.NetworkOnMainThreadException异常
- 有谁能帮忙推荐下Android+ssh开发案例的教程
- 黑马程序员Android28期视频免费下载地址,视频完整
- 可否直接调用openMAX的代码
- 打算一个月将android应用程序开发看一下,各位大虾给点建议
/** Called when the activity is first created. */
private static final String TAG="Activity01";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button mybutton=(Button) findViewById(R.id.button1);
mybutton.setOnClickListener(new Button.OnClickListener()
{ @Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.setClass(Activity01.this, Activity02.class);
startActivity(intent);
int version = Integer.valueOf(android.os.Build.VERSION.SDK);
if(version >= 5) {
overridePendingTransition(R.anim.zoom_in, R.anim.zoom_out);
//overridePendingTransition(android.R.anim.decelerate_interpolator,android.R.anim.decelerate_interpolator);
//overridePendingTransition(android.R.anim.overshoot_interpolator,android.R.anim.linear_interpolator);
}
Activity01.this.finish();
}
});
}
可以的,不过你要设置对应的动画效果,系统有提供,也可以自己定义,在res,文件下,新建anim,然后把描述动画的xml放进去,就可以像我一样用了。我的两个文件如下<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator">
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:fromYDelta="100%p"
android:toYDelta="0"
android:duration="1000"
/>
<scale
android:fromXScale="0.0"
android:toXScale="1.0"
android:fromYScale="0.0"
android:toYScale="1.0"
android:pivotX="0%"
android:pivotY="0%"
android:duration="1000"
/>
</set><?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"
android:zAdjustment="top">
<translate
android:fromYDelta="0"
android:toYDelta="100%p"
android:duration="1000"
/>
<scale
android:fromXScale="1.0"
android:toXScale="0.0"
android:fromYScale="1.0"
android:toYScale="0.0"
android:pivotX="0%"
android:pivotY="100%"
android:duration="1000"
/>
</set>需要整个项目可以找我。
Call immediately after one of the flavors of startActivity(Intent) or finish() to specify an explicit transition animation to perform next.
Parameters
enterAnim A resource ID of the animation resource to use for the incoming activity. Use 0 for no animation.
exitAnim A resource ID of the animation resource to use for the outgoing activity. Use 0 for no animation.
而且,好像我不自定义动画,系统默认的就有一个左出、右进的一个切换动画。