开发者

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

开发者 https://www.devze.com 2023-03-16 05:13 出处:网络
I just read a blogpost by Romain Guy on how to speed up an app开发者_JAVA百科 UI. He basically says that if your app uses opaque views you can set the background to @null in your Activity\'s style usi

I just read a blogpost by Romain Guy on how to speed up an app开发者_JAVA百科 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.


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 .

0

精彩评论

暂无评论...
验证码 换一张
取 消