Android进阶篇之引导页系列之Splash闪屏Log
2016-02-23 15:23
573 查看
在android应用中,其实闪屏是一个很重要的前期
先上效果图:就是一个页面
嗯,闪屏第一要做的就是展现自己的Logo,如果Logo好看,一眼就能留住用户,如果Logo和我的名字一样,
,用户肯定是屈指可数啊;第二,也是闪屏最重要的作用,就是利用闪屏的时间来做很多数据加载操作,这个也不难想到,如果直接进入数据比较多的主页时,那加载主页的承载负量就特别大,甚至会导致ANR<Application
no responsed>,所以基本上上线的产品大多数都会在闪屏的时候加载数据;第三,检查更新。。。
splash.xml文件,很简单,就是一个空的,设置背景,如果想设置自己的Logo可以直接写在里面
[java] view
plain copy
print?
<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"
android:background="@drawable/splash"
tools:context=".SplashActivity" >
</RelativeLayout>
SplashActivity.java,也很简单,没什么可说的。
[java] view
plain copy
print?
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;
public class SplashActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash);
new Handler().postDelayed(new Runnable() {
public void run() {
// Intent it = new Intent();
// it.setClass(SplashActivity.this, Login.class);
// startActivity(it);
finish();
}
}, 1000 * 2);
}
}
下面的代码,是将SplashActivity页面设置全屏,没有状态栏
[java] view
plain copy
print?
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
利用handler的延迟函数,然后在run方法中写要去的页面
[java] view
plain copy
print?
new Handler().postDelayed(new Runnable() {
public void run() {
// Intent it = new Intent();
// it.setClass(SplashActivity.this, Login.class);
// startActivity(it);
finish();
}
}, 1000 * 2);
代码下载
先上效果图:就是一个页面
嗯,闪屏第一要做的就是展现自己的Logo,如果Logo好看,一眼就能留住用户,如果Logo和我的名字一样,
,用户肯定是屈指可数啊;第二,也是闪屏最重要的作用,就是利用闪屏的时间来做很多数据加载操作,这个也不难想到,如果直接进入数据比较多的主页时,那加载主页的承载负量就特别大,甚至会导致ANR<Application
no responsed>,所以基本上上线的产品大多数都会在闪屏的时候加载数据;第三,检查更新。。。
splash.xml文件,很简单,就是一个空的,设置背景,如果想设置自己的Logo可以直接写在里面
[java] view
plain copy
print?
<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"
android:background="@drawable/splash"
tools:context=".SplashActivity" >
</RelativeLayout>
SplashActivity.java,也很简单,没什么可说的。
[java] view
plain copy
print?
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;
public class SplashActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash);
new Handler().postDelayed(new Runnable() {
public void run() {
// Intent it = new Intent();
// it.setClass(SplashActivity.this, Login.class);
// startActivity(it);
finish();
}
}, 1000 * 2);
}
}
下面的代码,是将SplashActivity页面设置全屏,没有状态栏
[java] view
plain copy
print?
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
利用handler的延迟函数,然后在run方法中写要去的页面
[java] view
plain copy
print?
new Handler().postDelayed(new Runnable() {
public void run() {
// Intent it = new Intent();
// it.setClass(SplashActivity.this, Login.class);
// startActivity(it);
finish();
}
}, 1000 * 2);
代码下载
相关文章推荐
- 安卓开发之安卓手电筒
- android—调试命令service
- Android开发之获取系统版本号
- Android Studio安装与配置
- Android性能优化总结
- 【Android动画】简单的组合动画按钮
- android系统版本与VERSION_CODES 值
- Android学习系列之控件 AutoCompleteTextView邮箱后缀自动补全
- Android内存性能优化(内部资料总结)
- 线程间通信的定义及全局变量的方法
- Android调试串口读写
- Android进阶篇之引导页系列之强大的SurfaceView实现动画引导页(2)
- android的task任务栈
- Android 如何让EditText不自动获取焦点
- Android进阶篇之引导页系列之强大的SurfaceView实现动画引导页(1)
- 浅学使用Android的mvp模式+otto消息总线
- Android 多线程
- Android进阶篇之引导页系列之ViewPager实现Animation动画引导页
- Android应用如何实现换肤功能
- Android TextView丰富多彩的字体样式代码