Search code examples
androidandroid-manifestandroid-theme

"Possible overdraw: Root element paints background "


While running Android Lint on my Project I came across this warning

Possible overdraw: Root element paints background @drawable/main with a theme that also paints a background

Where inferred theme is @android:style/Theme.NoTitleBar.Fullscreen

Can someone explain to me why is this coming and how to remove it ??

My 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" >

The part of manifest where theme is defined

 <application
        android:icon="@drawable/ic_logo"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >

Solution

  • To optimize your apps performance (avoid overdraw), you can do the following:

    • declare a theme in 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>
      

    • change the Manifest:

      <application
          android:icon="@drawable/ic_logo"
          android:label="@string/app_name"
          android:theme="@style/MyTheme" >
      
    • remove the background declaration in "My xml"