优化工具

2017-02-15  本文已影响0人  岛在深海处
一、Lint检查代码

1.This Handler class should be static or leaks might occur 解决办法

2.Android应用性能优化系列视图篇——LayoutInflater使用的正确姿势

3.getResources().getDrawable(R.drawable.xxx)方法过时问题:
替代方法:ContextCompat.getDrawable(Context context, R.drawable.xxx)

4.警告信息:Set android:baselineAligned="false" on this element for better performance
如果LinearLayout被用于嵌套的layout空间计算,它的android:baselineAligned属性应该设置成false,以加速layout计算
android:baselineAligned="false"

5.警告信息“Nested weights are bad for performance”的消除方法
原因分析:在布局进行嵌套使用时,父布局与子布局都使用了android:layout_weight,但不是必须使用时,便会出现如题所示的警告信息。
解决方法:根据实际情况,去除子布局中非必须使用的android:layout_weight

6。警告信息:Possible overdraw: Root element paints background @color/black with a theme that also paints a background
过度绘制,一般在主题中设置了background后xml文件的根布局就不要要设置bg了。

7,能用局部变量解决就尽量不要用全局变量,因为局部变量存储在栈中,与方法共存亡

上一篇 下一篇

猜你喜欢

热点阅读