很多应用都有启动页面,如何做一个高效的,退出应用后再进依旧能快速启动的启动页面。

直接贴代码

代码如下:启动页面Activity代码如下:

public class SplashScreen  extends BaseActivity{/*    * Called when the activity is first created.    */    @Override    public void onCreate(Bundle icicle) {        super.onCreate(icicle);        setContentView(R.layout.splashscreen);        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // 设置全屏,不需要可去掉        new Handler().postDelayed(new Runnable() {            public void run() {                /* Create an Intent that will start the Main WordPress Activity. */                Intent mainIntent = new Intent(SplashScreen.this, MainActivity.class);                SplashScreen.this.startActivity(mainIntent);                overridePendingTransition(R.anim.activity_in, R.anim.activity_out);// 淡出淡入动画效果                SplashScreen.this.finish();            }        }, 3000); //2900 for release    }}


AndroidManifest.xml配置如下

 <activity            android:name=".activity.SplashScreen"            android:launchMode="singleTop"            android:screenOrientation="portrait"            android:theme="@style/Theme.AppStartLoad">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>


styles.xml配置如下:

    <style name="Theme.AppStartLoad" parent="MainTheme">        <item name="android:windowBackground">@mipmap/aplash_back</item><!--一张图片-->        <item name="android:windowNoTitle">true</item>    </style>


overridePendingTransition(R.anim.activity_in, R.anim.activity_out);// 淡出淡入动画效果
这段代码是为了让启动页面淡化过渡到app的主页面 ,两个xml文件内容可到这里查看 点击打开链接



更多相关文章

  1. Unity3D与安卓原生的交互(二)
  2. Android(安卓)C++层打印调用栈
  3. Android(安卓)Studio报错:Could not GET 'https://dl.google.com*
  4. Android(安卓)在屏幕上打印LOG
  5. 关于手机启动的方向,和屏幕的单,双击事件
  6. Android(安卓)启动过程
  7. android app启动动画的实现
  8. Android(安卓)4.0 Launcher2源码分析——启动过程分析
  9. Android(安卓)Unable to resolve target "Android-14"

随机推荐

  1. 两分钟看完一道数学思想的算法题
  2. 这道算法题太简单?你忽略了时间复杂度的要
  3. 几道和散列(哈希)表有关的面试题
  4. 深度解析「正则表达式匹配」:从暴力解法到
  5. 五分钟知识小科普:什么是 Base64编码
  6. 几道和「二叉树」有关的算法面试题
  7. 小伙Python爬虫并自制新闻网站,太好玩了
  8. 昨天,终于拿到了腾讯 offer
  9. 独乐乐不如众乐乐,如何装逼的求众数
  10. 拜托,面试官别问我「布隆」了