当前位置:   article > 正文

View相关工具_view网站的开发工具

view网站的开发工具

2.View相关工具:
2.1.Hierarchyviewer
Hierarchy Viewer是随AndroidSDK发布的工具,位置在tools文件夹下,名为hierarchyviewer.bat,双击即可运行。它是Android自带的非常有用而且使用简单的工具,可以帮助我们更好地检视和设计用户界面(UI)。
具体来说主要功能有2个:
1. 从可视化的角度直观地获得UI布局设计结构和各种属性的信息,帮助我们优化布局设计;
2. 通过分析显示的measure,layout,draw的时间表现,可对View相关过程进行优化。
这里写图片描述
2.2.显示GPU过度绘制
可以在手机打开 设置–>开发者选项–>显示GPU过度绘制,这个开关的作用是按不同颜色值来显示布局的过度绘制,绘制的层次从最优到最差:
蓝–>绿–>淡红–>红:
蓝色 1x过度绘制
绿色 2x过度绘制
淡红色 3x过度绘制
红色 超过4x过度绘制
下图从上到下代表不同层次的OverDraw:

为了有更直观的认识,写了个简单的Demo: View优化_GPU过渡绘制
布局文件:view_overdraw_layout.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:background="#ffffff"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:background="#ffffff"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:background="#ffffff"
                android:orientation="horizontal" >

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:text="@string/ziroommobile" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:background="#ffffff"
                    android:text="@string/ziroommobile" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="@string/ziroommobile" />

</RelativeLayout>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52

页面显示如下图:
这里写图片描述
图片和第一组文字嵌套在三层写有背景的LinearLayout布局中,加上自身的图片或文字,那么它的颜色就成了红色(4X OverDraw),第二组文字,又加了背景属性,那么整个文字区域就都是红色(4X+ OverDraw)。
目标: 我们在布局时候,尽量减少红色Overdraw,看到更多的蓝色区域。
2.3.Android Lint
该工具主要是用来检查工程中代码的不合理,布局不合理,资源重复,图片重复等,让开发者进一步优化自己的应用。详细了解可网上搜索学习使用。
2.4.Android Studio
Android Stuido是Google推出,专门为Android“量身订做”的,是Google大力支持的一款基于IntelliJ IDEA改造的IDE。具有速度更快、UI更漂亮、更加智能、整合了Gradle构建工具、强大的UI编辑器、内置终端、更完善的插件系统、完美整合版本控制系统等诸多优点。是我们Android攻城狮修身立业之兵家利器。
详见李梦楠童鞋的Android Studio分享。
2.5.其他工具:
LeakCanary,处理内存泄露。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/831272
推荐阅读
相关标签
  

闽ICP备14008679号