android 启动页面
16lz
2021-12-12
很多应用都有启动页面,如何做一个高效的,退出应用后再进依旧能快速启动的启动页面。
直接贴代码
代码如下:启动页面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文件内容可到这里查看 点击打开链接
更多相关文章
- Unity3D与安卓原生的交互(二)
- Android(安卓)C++层打印调用栈
- Android(安卓)Studio报错:Could not GET 'https://dl.google.com*
- Android(安卓)在屏幕上打印LOG
- 关于手机启动的方向,和屏幕的单,双击事件
- Android(安卓)启动过程
- android app启动动画的实现
- Android(安卓)4.0 Launcher2源码分析——启动过程分析
- Android(安卓)Unable to resolve target "Android-14"