Androidapp启动时黑屏或者白屏的原因及解决办法

Androidapp启动时⿊屏或者⽩屏的原因及解决办法
1、产⽣原因
其实显⽰⿊屏或者⽩屏实属正常,这是因为还没加载到布局⽂件,就已经显⽰了window窗⼝背景,⿊屏⽩屏就是window窗⼝背景。
热熔胶网膜⽰例:
2、解决办法
通过设置设置Style
usb flash(1)设置背景图Theme
通过设置⼀张背景图。当程序启动时,⾸先显⽰这张背景图,避免出现⿊屏
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:screenOrientation">portrait</item>
<item name="android:windowBackground">>@mipmap/splash</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
</style>
(2)设置透明Theme
通过把样式设置为透明,程序启动后不会⿊屏⽽是整个透明了,等到界⾯初始化完才⼀次性显⽰出来
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:screenOrientation">portrait</item>
安息香乙醚
</style>
两者对⽐:
Theme1 程序启动快,界⾯先显⽰背景图,然后再刷新其他界⾯控件。给⼈刷新不同步感觉。
Theme2 给⼈程序启动慢感觉,界⾯⼀次性刷出来,刷新同步。
(3)修改l
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true">
<activity android:name=".MainActivity"
数字收音机
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
//......
</application>
解决后⽰例:
3、常见的Theme主题
外用药酒android:theme="@android:style/Theme.Dialog" //Activity显⽰为对话框模式
android:theme="@android:style/Theme.NoTitleBar" //不显⽰应⽤程序标题栏
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" //不显⽰应⽤程序标题栏,并全屏
android:theme="Theme.Light " //背景为⽩⾊
android:theme="Theme.Light.NoTitleBar" //⽩⾊背景并⽆标题栏
android:theme="Theme.Light.NoTitleBar.Fullscreen" //⽩⾊背景,⽆标题栏,全屏
android:theme="Theme.Black" //背景⿊⾊
android:theme="Theme.Black.NoTitleBar" //⿊⾊背景并⽆标题栏
android:theme="Theme.Black.NoTitleBar.Fullscreen" //⿊⾊背景,⽆标题栏,全屏
android:theme="Theme.Wallpaper" //⽤系统桌⾯为应⽤程序背景
android:theme="Theme.Wallpaper.NoTitleBar" //⽤系统桌⾯为应⽤程序背景,且⽆标题栏
android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" //⽤系统桌⾯为应⽤程序背景,⽆标题栏,全屏
android:theme="Theme.Translucent" //透明背景
android:theme="Theme.Translucent.NoTitleBar" //透明背景并⽆标题
android:theme="Theme.Translucent.NoTitleBar.Fullscreen" //透明背景并⽆标题,全屏
android:theme="Theme.Panel " //⾯板风格显⽰
胶衣树脂android:theme="Theme.Light.Panel" //平板风格显⽰
以上就是对Android app启动时⿊屏或者⽩屏的原因及解决办法的资料整理,后续继续补充相关资料,谢谢⼤家对本站的⽀持!

本文发布于:2024-09-21 17:57:16,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/3/277418.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:程序   背景   透明   资料   标题栏   刷新
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议