如何在Android中2活动之间滑动动画?

编程入门 行业动态 更新时间:2024-10-19 14:26:47
本文介绍了如何在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:机器人=htt​​p://schemas.android/apk/res/android  机器人:时间=5000  机器人:fromAlpha =0.0  机器人:插=@机器人:动画/ slide_out_right  机器人:toAlpha =1.0> < /阿尔法>

fadeout.xml

< XML版本=1.0编码=UTF-8&GT?; <阿尔法  的xmlns:机器人=htt​​p://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活动之间滑动动画?

本文发布于:2023-08-01 12:31:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1268373.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:动画   如何在   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!