Search code examples
androidandroid-layoutandroid-viewandroid-tablelayoutlayout-inflater

Avoid high overdraw and long View drawing


I have a problem with a BI application I'm writing.

The application uses AChartEngine for charts and most of the table data is inflated programmatically. There are currently two main problems I'm facing:

  1. When the application switches orientation, it takes around 8-10 seconds to redraw every dashboard element (i.e. to display data). Is this a problem with overdraw or something else (this happens on N4, N5, Note 3...). This is unacceptable and I really need to fix this!
  2. There's almost 4x overdraw on table row elements, and I managed to get it lower - to around 2-2.5x with getWindow().setBackgroundDrawable(null). How do I fix this much overdraw as everything is inflated from code? (here's an example of how it looks like: http://prntscr.com/2lio5q).

Solution

  • I finally fixed the orientation working very slowly. I applied few flags to my FragmentActivity in the manifset and it works much better now, flags are android:configChanges="screenSize|orientation|keyboardHidden".

    Keep in mind that for this kind of thing it is much better and Android-like to use the FragmentPagerAdapter than FragmentActivity, but I work with what I got.

    Hope this helps someone!