Android-Op

作者: 青楼爱小生 | 来源:发表于2019-10-28 16:47 被阅读0次

    Android 优化篇

    布局优化/绘制优化
    • 原则
      避免嵌套过多,可采用约束布局
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    
    • 工具
      Android Studio在tools菜单栏选择layout工具查看


      Layout Inspector

    内存优化
    • 原则
      避免创建过多不必要的对象,尤其是在循环中
      比如不要在onDraw中new Paint
    • 工具
      查询内存泄漏
      LeakCanary
    cpu优化
    • 原则
      避免多次执行同一个耗时方法
    • 工具
      TraceView 可找出单次执行耗时方法和多次调用的方法

      Android5.0 AS3.0之后可使用 Profiler
    网络优化

    车机项目中使用本地较多,暂略

    电量优化

    昝略

    apk体积优化
    • 原则
      1.去除不用的资源
      2.开启混淆
      3.新型构建工具Bundle
    • 工具
      Lint
      静态代码检测工具


      Lint
    双击Shift开启搜索,输入 去除多余资源

    相关文章

      网友评论

        本文标题:Android-Op

        本文链接:https://www.haomeiwen.com/subject/iqmbvctx.html