Android Performance in Practice

I recently wrote an article explaining how to track down and fix performance issues in Android application. This article was by no means a complete reference on how to solve all performance issues and focused on a particular set of issues caused by overdraw.

To help you better understand how to fix overdraw issues, I would like to invite you to download a small Android application I wrote (click File > Download to download the entire archieve.)

Your goal will be to use the tools described in my previous article to find and fix the 3 main overdraw issues in the app. If you do it right, you should turn the image on the left to the image on the right:

16 Responses to “Android Performance in Practice”

  1. Gamma says:

    Thanks for the previous post, and the practical training !

  2. Marcus K├Ârner says:

    I guess the most tricky part is to cut out the nine-patch drawable ;)

  3. Swaminatha Prabhu says:

    I have a question. Our team used to strictly obey the Lint warnings. The recent Lint enhancements are awesome.
    For your project, the lint warning reported as below for the file activity_main.xml

    Possible overdraw: Root element paints background @color/dark_background with a theme that also paints a background (inferred theme is @style/AppTheme)

    Going by the above suggestion we achieved the right side image. Now my question(confused), for finding the overdraw which one you suggest?? Lint or the debug methodology you suggested.

  4. Afzal says:

    Hmm…after I finished fixing the 9-patch and set background drawable to null, my ActionBar background had no colour and the text + icon were blue, instead of green. :)

    Thanks for this exercise Romain

  5. is anyone else having a problem with “getWindow().setBackgroundDrawable(null);” having no effect to the overdraw? It works fine when it’s in the theme but not programmatically in onCreate()

  6. T says:

    Any response to the problem reported about setting windowbackground to @null causing “smearing”? See:

    Afraid to try it because of that bug report.

  7. amor egypt says:

    could you talk about building custom list view from scratch with a high performance

  8. amor egypt says:

    could you talk about building custom list view from scratch with a high performance

  9. Afzal says:

    @Josh, I didn’t have a problem with that.

  10. Josh says:

    @Afzal/Anyone, hmmm. I see no difference at all. Do you? getWindow().setBackgroundDrawable(null) seems to have has no affect on overdraw. Sample is below.

    protected void onCreate(Bundle savedInstanceState) {

    and main.xml is just 2 view containers.

  11. Josh says:

    WP is stripping out the xml… the xml for main.xml is just 2 containers both have a background color. The inner once has 20 dp padding on the left and right so you can see the overdraw layers.

  12. Romain Guy says:

    Call setBackgroundDrawable(null) after setContentView() and see if it helps.

  13. ursus says:

    Will there be a solution published?

  14. he.cao says:

    replace @drawable/frame to @drawable/frame_hole in layout/photo_item.xml will do most of the work.