android:windowBackground="@null" to improve app speed-ThrowExceptions

Exception or error:

I just read a blogpost by Romain Guy on how to speed up an app UI. He basically says that if your app uses opaque views you can set the background to @null in your Activity‘s style using:

<item name="android:windowBackground">@null</item>

Does this work? I was willing to test this using FPS as he did but I didn’t find a clear way of getting that info.

I have read some threads saying you need to do it yourself.
I am about to add a custom view that draws the FPS in the onDraw() method and calls invalidate() to get call all the time.

Although this works, I would like to know if there is a better way to analyse FPS in an application.

How to solve:

That blogpost has a source code of samples. Check FpsImageView.java.

###

If the UI of your application is completely drawing the window contents, you should always set windowBackground to null. This prevents the framework from filling your window with the default background color, so it is one less pass that is needed to render each frame which means you can spend your own time drawing that number of pixels.

###

on some cases , i’ve noticed that setting the background to null causes weird ui glitches , as written here .

i would recommend to test it in various devices and on the emulator before deciding to have it .

Leave a Reply

Your email address will not be published. Required fields are marked *