speeding up app in android

来源:互联网 发布:二战网络射击游戏 编辑:程序博客网 时间:2024/06/05 22:52

1. View.onDraw( ) method is a very performance-criticalpiece of code, so it’s best to do as little as possible there.

• If possible, avoid doing any object allocations in the method onDraw( ).
• Prefetch things such as color constants elsewhere (for example, in the view’s constructor).
• Create your Paint objects up front, and just use existing instances in onDraw( ).
• For values used multiple times, such as the width returned by getWidth( ), retrieve the value at the beginning of the method and then access it from your local copy.

2. // TODO Continue to sum up


原创粉丝点击