使自定义主题使用null背景(Android lint建议)

pgs*_*rom 12 android android-layout android-lint

我正在阅读关于新的Android Lint规则,并且我发现要防止透支我应该使我的背景布局使用具有空背景的主题,以防止如果我只是要覆盖它来绘制背景.问题是,如何定义具有空背景的自定义主题?

失败尝试1(不编译):

<style name="NoTitleBarNoBackground" parent="@android:style/Theme.NoTitleBar">
        <item name="android:background">null</item>
</style>
Run Code Online (Sandbox Code Playgroud)

失败尝试2(警告仍然存在):

<style name="NoTitleBarNoBackground" parent="@android:style/Theme.NoTitleBar">
        <item name="android:background">#00000000</item>
</style>
Run Code Online (Sandbox Code Playgroud)

Dim*_*ris 36

你可以试试这个:

<style name="CustomTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowBackground">@null</item>
    </style>
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助!

  • 最近的研究表明你是一位绅士和学者 (6认同)