14

Im reading about the new Android Lint rules, and I find to prevent overdraw I should make my layouts with a background use a theme with null background, to prevent a background to be drawn if Im just gonna overwrite it. The problem is, how do I define a custom theme with null background?

Fail attempt 1 (doesn't compile):

<style name="NoTitleBarNoBackground" parent="@android:style/Theme.NoTitleBar">
        <item name="android:background">null</item>
</style>

Fail attempt 2 (warning persists):

<style name="NoTitleBarNoBackground" parent="@android:style/Theme.NoTitleBar">
        <item name="android:background">#00000000</item>
</style>
Bananeweizen
  • 21,797
  • 8
  • 68
  • 88
pgsandstrom
  • 14,361
  • 13
  • 70
  • 104

1 Answers1

39

You can try this:

<style name="CustomTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowBackground">@null</item>
    </style>

Hope this helps!

Dimitris Makris
  • 5,183
  • 2
  • 34
  • 54