本文介绍了如何在Android中2活动之间滑动动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想滑块向左向右效果时,我改变了活动,并为我使用下面的code 但没有得到任何结果。请电流我。 谢谢
在java中这两个文件
super.onCreate(savedInstanceState); overridePendingTransition(R.anim.fadein,R.anim.fadeout); 的setContentView(R.layout.main);在RES /阿尼姆目录两个文件 fadein.xml
< XML版本=1.0编码=UTF-8&GT?; <阿尔法 的xmlns:机器人=http://schemas.android/apk/res/android 机器人:时间=5000 机器人:fromAlpha =0.0 机器人:插=@机器人:动画/ slide_out_right 机器人:toAlpha =1.0> < /阿尔法>
fadeout.xml
< XML版本=1.0编码=UTF-8&GT?; <阿尔法 的xmlns:机器人=http://schemas.android/apk/res/android 机器人:时间=5000 机器人:fromAlpha =0.0 机器人:插=@机器人:动画/ slide_in_left 机器人:toAlpha =1.0> < /阿尔法>解决方案
保护无效的onCreate(包savedInstanceState){ super.onCreate(savedInstanceState); 的setContentView(R.layout.splashscreen); 新的处理程序()。postDelayed(新的Runnable(){ 公共无效的run(){ / *创建一个意图将启动的主要活动。 * / 意图mainIntent =新的意图(SplashScreen.this, ConnectedActivity.class); mainIntent.putExtra(ID,1); //SplashScreen.this.startActivity(mainIntent); startActivity(mainIntent); / *完成飞溅活动,以便用户不能回去吧。 * / SplashScreen.this.finish(); / *运用我们的防溅出口(淡出)和主 条目(淡入)的动画转换。 * / overridePendingTransition(R.anim.mainfadein,R.anim.splashfadeout); } },SPLASH_DISPLAY_TIME); }I want slide effect left to right when I change the Activity and for that I am using following code but not getting any result. please current me. Thanks
in java both file
super.onCreate(savedInstanceState); overridePendingTransition(R.anim.fadein, R.anim.fadeout); setContentView(R.layout.main);two files in res/anim directory fadein.xml
<?xml version="1.0" encoding="utf-8"?> <alpha xmlns:android="schemas.android/apk/res/android" android:duration="5000" android:fromAlpha="0.0" android:interpolator="@android:anim/slide_out_right" android:toAlpha="1.0" > </alpha>fadeout.xml
<?xml version="1.0" encoding="utf-8"?> <alpha xmlns:android="schemas.android/apk/res/android" android:duration="5000" android:fromAlpha="0.0" android:interpolator="@android:anim/slide_in_left" android:toAlpha="1.0" > </alpha>解决方案 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splashscreen); new Handler().postDelayed(new Runnable() { public void run() { /* Create an intent that will start the main activity. */ Intent mainIntent = new Intent(SplashScreen.this, ConnectedActivity.class); mainIntent.putExtra("id", "1"); //SplashScreen.this.startActivity(mainIntent); startActivity(mainIntent); /* Finish splash activity so user cant go back to it. */ SplashScreen.this.finish(); /* Apply our splash exit (fade out) and main entry (fade in) animation transitions. */ overridePendingTransition(R.anim.mainfadein,R.anim.splashfadeout); } }, SPLASH_DISPLAY_TIME); }
更多推荐
如何在Android中2活动之间滑动动画?
发布评论