Android闪屏欢迎界面的实现
来源:互联网 发布:淘宝领金币怎么没有了 编辑:程序博客网 时间:2024/06/07 15:30
闪屏:在打开App时,展示,持续数秒后,自动关闭,进入另外的一个界面,SplashActivity跳转到MainActivity
android中有三种实现方法
xml代码:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.administrator.test.SplashActivity"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/splash_iv" android:scaleType="fitXY" android:src="@mipmap/splash"/></RelativeLayout>
(1)利用Handler对象的postDelayed方法可以实现,传递一个Runnable对象和一个需要延时的时间即可
new Handler().postDelayed(new Runnable() { @Override public void run() { Intent intent=new Intent(SplashActivity.this,MainActivity.class); startActivity(intent); SplashActivity.this.finish(); } },3000);
(2)使用动画持续时间,动画结束后进行跳转
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); iv =(ImageView)findViewById(R.id.splash_iv); iv.setImageResource(R.mipmap.splash); //设置透明度动画从无到有 AlphaAnimation alphaAnimation=new AlphaAnimation(0.0f,1.0f); //设置动画持续时间 alphaAnimation.setDuration(3000); //开始显示动画 iv.startAnimation(alphaAnimation); //给动画设置监听,在动画结束的时候进行跳转 alphaAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { //动画开始时执行 Log.e("TAG", "onAnimationStart: " ); } @Override public void onAnimationEnd(Animation animation) { //动画结束时执行 Log.e("TAG", "onAnimationEnd: " ); Intent intent=new Intent(SplashActivity.this,MainActivity.class); startActivity(intent); finish(); } @Override public void onAnimationRepeat(Animation animation) { //动画重复播放时执行 Log.e("TAG", "onAnimationRepeat: " ); } }); }
(3)利用Timer定时器实现,
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); iv =(ImageView)findViewById(R.id.splash_iv); iv.setImageResource(R.mipmap.splash); Timer timer=new Timer(); timer.schedule(new TimerTask() { @Override public void run() { Intent intent=new Intent(SplashActivity.this,MainActivity.class); startActivity(intent); finish(); } },3000); }
0 0
- Android闪屏欢迎界面的实现
- Android实现闪屏欢迎界面
- 【Android】欢迎界面的实现
- android 实现欢迎界面
- android几种欢迎界面的实现
- Android实现全屏图片的欢迎界面
- Android实现全屏图片的欢迎界面
- android几种欢迎界面的实现 .
- android中欢迎界面的实现
- android中 欢迎界面的实现
- Android实现全屏图片的欢迎界面
- Android实现欢迎界面的自动跳转
- Android实现欢迎界面的自动跳转
- Android应用的欢迎界面动画实现
- [Android效果]Android中实现闪屏的欢迎界面
- android闪屏欢迎界面
- android 使用webView加载欢迎界面的个人实现思路,实现欢迎界面不断在改变
- Android实现定时欢迎界面
- jdk1.8新特性之Lambda表达式及在Android Studio中的使用
- nodejs安装
- 这交互炸了(三):闪屏页是像云一样消失的
- 面向对象理解
- 【知识分享】美句收藏二
- Android闪屏欢迎界面的实现
- 查linux的cpu内存情况
- [代码笔记] python 之嵌套列表(多维数组)之转置
- 谈谈互联网后端基础设施
- Linux系统下连接Oracle数据库,创建新的数据库用户及分配权限
- 每天一个linux命令(20):find命令之exec
- 贝叶斯画树
- Eclipse android项目中配置NDK自动编译生成so文件
- HTML5基础(列表、块、布局、表单、实体)