假如果是Activity1启动Activity2:即在Activity中startActivity(//Activity2);而现在我要让Activity1慢慢消失,Activity2慢慢出现,而不是系统默认的直接出现来到前台。
在网上有人说在startActivity()之后加上overridePendingTransition(enterAnim, exitAnim)方法,但我都试了好多遍,还是不行。求大师讲解?????????????
在网上有人说在startActivity()之后加上overridePendingTransition(enterAnim, exitAnim)方法,但我都试了好多遍,还是不行。求大师讲解?????????????
解决方案 »
- adb shell su后为什么不能输入了?
- android:targetSdkVersion 和android:hardwareAccelerated引发的惨案
- android settings ballery中的电量蓝线 断断续续的是什么原因
- 运行时报ResourceNotFound
- FragmentActivity 在切换 Fragment时触发什么事件
- 紧急求助 原先SDK是4.0时没问题 换成2.3.1后运行时出现如下错误
- 如何把EditText与百度或谷歌的搜索关联???
- contentprovider 查询 联系人存在不存在
- 低版本兼容使用Fragment
- CoordinatorLayout ,AppBarLayout 如何滚动到指定位置
- 可否直接调用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.
而且,好像我不自定义动画,系统默认的就有一个左出、右进的一个切换动画。