Reduce Overdraw from Your Android Application

Always remember PerfMatters….

Image Source: https://io2015codelabs.appspot.com/codelabs/android-performance-debug-gpu-overdraw

What is basically an overdraw?? An overdraw refers to a system that drawing the pixel to the screen multiple times

It is important to reduce as much as you can according to the performance.

How to check the overdraw in the application:

  1. On your device, go to Settings and tap Developer Options.
  2. Scroll down to the Hardware accelerated rendering section, and select Debug GPU Overdraw.
  3. In the Debug GPU overdraw dialog, select Show overdraw areas.

There are four colors for overdraw which tell us how many times the pixel is drawn on the screen, so let’s jump into it.

Image Source: https://developer.android.com/studio/profile/inspect-gpu-rendering#debug_overdraw

Let’s Start With The Practical Example:

I made a simple application in which I have two views like below screenshot:

OverDraw

XML:

Now let’s open the Debug GPU overdraw and we will see the overdraw.

Overdraw visible

You can see the highlighted one some red and green one which means red draw 4 times and green draw 2 times.

Solution:

The solution to reduce the overdraw is first you need to check in your child views that have you defined the background color in the child view if yes then remove it from your child views, like in the above code which I mentioned I defined the background color in my parent layout as well as in the child views, so lets remove them then we will see how much the overdraw reduces.

Reduce Overdraw

Now in the above screenshot, you can see some extent I reduce the overdraw. After removing from your XML layout file, then you need to set the background drawable to null in your code to reduce the overdraw more, let’s implement in java code.

Result:

Reduce Overdraw

So after all this, you can see from the above screenshot, we reduce the overdraw from our sample application.

If you need to know more about it check out the official link below:

Thanks for reading this article. Be sure to clap to recommend this article if you found it helpful. It means a lot to me.

If you need any help then Join me on Twitter, Linkedin, Github, and Subscribe to my Youtube Channel.

Senior Software Engineer(Android). Open Source Contributor, Technical Writer, Email: Dani.amjad12@gmail.com check my website at https://danishamjad.com/

The (retired) Pub(lication) for Android & Tech, focused on Development