设为首页 加入收藏

TOP

Android app targetSdk升级到27碰到的一个bug补充说明
2019-09-03 03:43:12 】 浏览:57
Tags:Android app targetSdk 升级 碰到 一个 bug 补充 说明

版权声明:本文为xing_star原创文章,转载请注明出处!

本文同步自http://javaexception.com/archives/203

完美解决google nexus设备全面屏主题crash问题

前面有一篇文章,记录了我在app升级到targetSdk 27中,出现的bug,文章位于 http://javaexception.com/archives/184 。

问题很奇怪,只在google nexus上出现,经过对特定的关键词搜索,在stackoverflow上找到了一篇有价值的文章 https://stackoverflow.com/questions/48072438/java-lang-illegalstateexception-only-fullscreen-opaque-activities-can-request-o

在我的app中,设置的全屏主题样式如下:

<style name="AppTheme.NoActionBar.Fullscreen" parent="AppTheme.NoActionBar">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@android:color/transparent</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowFullscreen">true</item>
</style>

这个回答https://stackoverflow.com/a/52964692/5279354 下面有一个很有价值的评论回复。

To anyone else who stumbles upon this “fix” I had to set <item name="android:windowIsTranslucent">false</item> and also had to set <item name="android:windowIsFloating">false</item> before it would work.

按照这个说法,需要调整下全屏的主题样式,修改后的结果是

<style name="AppTheme.NoActionBar.Fullscreen" parent="AppTheme.NoActionBar">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@android:color/transparent</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowIsTranslucent">false</item>
    <item name="android:windowIsFloating">false</item>
</style>

到此终于完美的解决问题。修改样式后,app的targetSdk是27以及以上,都不会再导致google nexus系列的设备crash。

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Android开发之输入框EditText介绍 下一篇错题本:ConstraintLayout 不能正..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目