最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android app啟動時(shí)黑屏或者白屏的原因及解決辦法

 更新時(shí)間:2016年09月21日 17:19:35   投稿:lqh  
這篇文章主要介紹了Android app啟動時(shí)黑屏或者白屏的原因及解決辦法的相關(guān)資料,需要的朋友可以參考下

1、產(chǎn)生原因

其實(shí)顯示黑屏或者白屏實(shí)屬正常,這是因?yàn)檫€沒加載到布局文件,就已經(jīng)顯示了window窗口背景,黑屏白屏就是window窗口背景。

示例:

2、解決辦法

通過設(shè)置設(shè)置Style

(1)設(shè)置背景圖Theme

通過設(shè)置一張背景圖。 當(dāng)程序啟動時(shí),首先顯示這張背景圖,避免出現(xiàn)黑屏

<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)設(shè)置透明Theme

通過把樣式設(shè)置為透明,程序啟動后不會黑屏而是整個(gè)透明了,等到界面初始化完才一次性顯示出來

<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)修改AndroidManifest.xml

<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" //不顯示應(yīng)用程序標(biāo)題欄

android:theme="@android:style/Theme.NoTitleBar.Fullscreen" //不顯示應(yīng)用程序標(biāo)題欄,并全屏

android:theme="Theme.Light " //背景為白色

android:theme="Theme.Light.NoTitleBar" //白色背景并無標(biāo)題欄

android:theme="Theme.Light.NoTitleBar.Fullscreen" //白色背景,無標(biāo)題欄,全屏

android:theme="Theme.Black" //背景黑色

android:theme="Theme.Black.NoTitleBar" //黑色背景并無標(biāo)題欄

android:theme="Theme.Black.NoTitleBar.Fullscreen" //黑色背景,無標(biāo)題欄,全屏

android:theme="Theme.Wallpaper" //用系統(tǒng)桌面為應(yīng)用程序背景

android:theme="Theme.Wallpaper.NoTitleBar" //用系統(tǒng)桌面為應(yīng)用程序背景,且無標(biāo)題欄

android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" //用系統(tǒng)桌面為應(yīng)用程序背景,無標(biāo)題欄,全屏

android:theme="Theme.Translucent" //透明背景

android:theme="Theme.Translucent.NoTitleBar" //透明背景并無標(biāo)題

android:theme="Theme.Translucent.NoTitleBar.Fullscreen" //透明背景并無標(biāo)題,全屏

android:theme="Theme.Panel " //面板風(fēng)格顯示

android:theme="Theme.Light.Panel" //平板風(fēng)格顯示

以上就是對Android app啟動時(shí)黑屏或者白屏的原因及解決辦法的資料整理,后續(xù)繼續(xù)補(bǔ)充相關(guān)資料,謝謝大家對本站的支持!

相關(guān)文章

最新評論

平昌县| 枣阳市| 都江堰市| 邯郸市| 集安市| 阿拉善右旗| 建阳市| 建瓯市| 东海县| 石家庄市| 霍山县| 郓城县| 绵竹市| 义马市| 唐河县| 乌拉特中旗| 耒阳市| 巴东县| 岳阳县| 曲阳县| 宾阳县| 河源市| 乌拉特中旗| 汉中市| 沭阳县| 湄潭县| 乾安县| 惠来县| 卓尼县| 兴文县| 达拉特旗| 光山县| 太仆寺旗| 双牌县| 洛隆县| 灌南县| 嘉祥县| 陇川县| 巨鹿县| 洞头县| 泰和县|