Sun*_*tya 28 android android-manifest android-theme
在我的项目上运行Android Lint时,我遇到了这个警告
可能的透支:根元素绘制背景@ drawable/main,主题也绘制背景
推断主题在哪里 @android:style/Theme.NoTitleBar.Fullscreen
有人可以向我解释为什么会这样,以及如何删除它?
我的xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/main" //***LINT warning***
android:orientation="vertical"
android:weightSum="3" >
Run Code Online (Sandbox Code Playgroud)
清单中定义主题的部分
<application
android:icon="@drawable/ic_logo"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
Run Code Online (Sandbox Code Playgroud)
nvr*_*dow 21
要优化应用程序性能(避免透支),您可以执行以下操作:
声明一个主题 res/values/styles.xml
<style name="MyTheme" parent="android:Theme">
<item name="android:background">@drawable/main</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
改变清单:
<application
android:icon="@drawable/ic_logo"
android:label="@string/app_name"
android:theme="@style/MyTheme" >
Run Code Online (Sandbox Code Playgroud)Sot*_*tti 13
更新
查看评论或查看此链接.正如Marcin所提到的,我的解决方案并不是一个好方法,因为它可能会导致人工制品.我一直在使用它来避免长时间透支而没有任何问题,但根据Chet Haase对这种技术的评论,一般情况下可能不是规则的拇指.
原始答案
我发现的最佳方法是将默认背景设置为null,并在每个布局中应用所需的背景.
原因是当您在主题中设置默认背景,或者甚至是如上所述的具有不同背景的不同主题时,这意味着整个布局将填充该背景.在大多数情况下,您不需要填充100%的背景,因为您在该背景上有工具栏,页眉,页脚和其他元素会导致过度绘制.
要在主题上应用空背景:
<style
name="ThemeName" parent="ParentTheme">
<item name="android:windowBackground">@null</item>
</style>
Run Code Online (Sandbox Code Playgroud)
要检查overdraw,只需激活模拟器/设备上dev选项中的Show Overdraw选项.不要相信100%lint警告,因为跟踪器中存在一些我不确定完全修复的错误.
更多信息: 什么是透支,为什么是问题?
| 归档时间: |
|
| 查看次数: |
15163 次 |
| 最近记录: |