默认的情况下,程序启动时,会有一个黑屏的时期,原因是,首个activity会加载一些数据,比如初始化列表数据等。具体步骤如下: 
1./res/values/styles.xml 在 Theme 中,添加一个 android:windowBackgrounds 属性,设置需要的图片
2.在 AndroidManifest.xml 中设置Theme到首个启动的Activity下
3.添加 /res/drawable-port/loading.png (若是横屏的启动画面,请放于 /res/drawable-land/loading.png )
4.完成 
参考代码:

<style name="MyTheme.NoTitleBar.CustomBackground" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowBackground">@mipmap/ic_logo</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
清单配置文件中使用方式如下:

<activity
android:name=".ui.activity.WelcomeActivity"
android:theme="@style/MyTheme.NoTitleBar.CustomBackground"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>





转载于:https://www.cnblogs.com/linux007/p/5782862.html

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐