Android 解决启动白屏
来源:互联网 发布:steam淘宝 编辑:程序博客网 时间:2024/06/06 14:23
之所以因为启动一个应用会白屏,是因为在加载启动Activity之前,会显示StartingWindow,我们可以通过设置Style的背景图片来解决这个问题。
这个图片自己可以随便弄,美观简约就好
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 背景颜色 --> <item android:drawable="@color/white" /> <item> <!-- 图片 --> <bitmap android:gravity="center" android:src="@mipmap/ic_launcher" /> </item></layer-list>
设置背景图片,但记得单独弄一个style,因为所有Activity布局背景都是透明的,启动activity后可能会还能看到图片
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="SplashTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:windowBackground">@drawable/splash</item> </style></resources>
单独给SplashActivity设置style
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="site.gemus.fancyview"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> </activity> <activity android:name=".SplashActivity" android:theme="@style/SplashTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
直接启动activity,不用设置布局,为了加速启动
public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); startActivity(new Intent(this, MainActivity.class)); finish(); }}
关于加速启动,我只有一个建议,那就是在我们自定义Application里尽量异步加载或者少放一些代码,因为应用启动先加载Application,再加载Activity
阅读全文
0 0
- Android 解决启动白屏
- Android 启动 白屏问题 解决
- Android 启动 白屏问题 解决
- android 启动白屏问题完美解决
- android 秒启动解决启动白屏,黑屏现象
- Android应用启动时黑屏或白屏的解决
- Android开始启动白屏的原因分析及解决
- android全屏启动页[解决黑屏白屏]
- Android开发之解决App启动白屏或黑屏
- [Android]Splash界面解决启动白屏/黑屏问题
- Android 解决启动app白屏或黑屏的问题
- Android--app启动 黑白屏问题 解决
- 解决android应用启动白屏问题——android 的冷启动
- android adb启动失败解决
- Android ADB 启动不成功解决
- 解决Android Studio启动失败
- Android启动白屏
- Android 启动白屏
- mac 个人网站收藏(二)
- 项目大神(项目经理)的修炼 ——挑战五十万年薪(广州站)
- Linux 安装nginx 1.8.1 及配置
- Linux下编译动态库及使用
- django学习记录
- Android 解决启动白屏
- js模拟手机短信发送
- 关于问题The fully qualified name of the bean's class, except if it serves only as a parent definition fo
- codeblocks出现无法调试或断点失效问题解决办法
- elasticsearch设置refresh_interval-1的思考
- mysql 基础知识
- CentOS 7安装部署Rsync数据同步服务器
- iOS .ips(crash)崩溃报告文件分析
- 机器学习的框架(新手)