您的位置:首页 > 移动开发 > Android开发

android 启动页面

2016-02-16 10:53 531 查看
很多应用都有启动页面,如何做一个高效的,退出应用后再进依旧能快速启动的启动页面。

直接贴代码

代码如下:启动页面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文件内容可到这里查看
点击打开链接
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: