Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible overdraw: Root element paints background with a theme that also paints a background

I have implemented clickable Recyclerview item and set android:background="?selectableItemBackground" for click effect but while inspecting code I found this lint issue.

Lint warning : Possible overdraw: Root element paints background ?selectableItemBackground with a theme that also paints a background

Any idea to solve this warning?

My xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?selectableItemBackground"
    android:clickable="true"
    android:orientation="vertical"
    android:padding="@dimen/row_padding">

    //...
</LinearLayout >
like image 690
Pratik Popat Avatar asked Feb 13 '17 07:02

Pratik Popat


1 Answers

By default, a theme has android:windowBackground attribute specified, which specifies, as the name implies, the background of the window, where your activity is being launched.

This lint warning just tells you following:

Hey! I see your theme has a windowBackground applied, and your root layout draws some other drawable on top of window background, making window's background pointless - thus overdrawing pixels needlessly.

Nulling out windowBackground would make lint not to complain:

<style name="AppTheme" parent="...">
    ...
    <item name="android:windowBackground">@null</item>
</style>
like image 110
azizbekian Avatar answered Nov 04 '22 08:11

azizbekian