Android启动页SplashScreen实现
来源:互联网 发布:广联达软件最新版本 编辑:程序博客网 时间:2024/06/13 17:05
SplashScreen也叫做启动页,通常用于在程序启动时作为引导,有需要的话也可以进行一些数据的初始化,自动登陆的操作等等。最近项目中要添加一个启动页的功能,实现起来非常简单,跟大家分享一下。
首先在xml文件里放置一个imageview用来显示图片:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ImageView android:id="@+id/iv_splash" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" android:src="@drawable/splash_screen" android:contentDescription="@string/app_name" /></LinearLayout>
给图片加上相应的动画效果:
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false" > <!-- 透明度从0.5到1 --> <alpha android:duration="3000" android:fromAlpha="0.5" android:interpolator="@android:res/anim/accelerate_decelerate_interpolator" android:toAlpha="1.0" > </alpha> <!-- 从中心放大,从1到1.2 --> <scale android:duration="3000" android:fromXScale="1.0" android:fromYScale="1.0" android:interpolator="@android:res/anim/accelerate_decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:toXScale="1.2" android:toYScale="1.2" > </scale></set>
停留三秒钟自动进入登陆或者其他的界面。Java代码:
public class SplashScreenActivity extends Activity { //持续时间 private static final int DELAY_TIME = 3000; private ImageView splashImageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash_screen); splashImageView = (ImageView) findViewById(R.id.iv_splash); Animation animation = AnimationUtils.loadAnimation(this, R.anim.alpha_scale_translate); animation.setFillAfter(true);//保持动画不还原 splashImageView.setAnimation(animation); //设置动画 new Handler().postDelayed(new Runnable() { public void run() { Intent i = new Intent(SplashScreenActivity.this, LoginActivity.class); // 跳转到登陆界面 SplashActivity.this.startActivity(i); // 启动登陆界面 finish(); // 结束Acitivity } }, DELAY_TIME); } }
0 0
- Android启动页SplashScreen实现
- Cocoa下实现SplashScreen
- SplashScreen实现加载数据
- Mymusic SplashScreen界面实现
- React Native Splashscreen实现
- wxPython:启动画面SplashScreen介绍
- SplashScreen
- cordova SplashScreen插件在android上退出app后不再显示启动画面的问题
- 程序启动画面——SplashScreen
- JAVA 闪屏 SplashScreen 程序启动画面 浅谈
- Qml 实现一个简单的SplashScreen
- android 启动页 实现
- appframework和phongGap启动画面(splashscreen)--拒绝启动黑屏
- VC++2010工程中加入SplashScreen的启动画面
- 开源项目--来电管理精灵(一) 线程实现SplashScreen
- WPF启动界面(SplashScreen)在安装部署后启动不了的问题
- Android轻松实现高效的启动页
- Android 利用kenBurnsView实现启动页
- 2-8-3 分数类中的运算符重载
- JavaWeb项目导入MyEclipse后变为JAVA项目项目【解决方法】
- php json 定义转换问题
- sql - w3c_01
- linux远程登录ssh免密码
- Android启动页SplashScreen实现
- Linux下解压缩文件
- jquery easyui combobox设置默认选中第一项
- Session的原理
- Jquery中的$.get()方法返回值有多余空格问题
- JDBC连接数据库
- Storage Metrics
- AndroidManifest.xml配置文件详解
- JAVA Web项目开发乱码问题备忘