什么是HierarchyViewer

Hierarchy Viewer是随AndroidSDK发布的工具,位置在tools文件夹下,名为hierarchyviewer.bat。它是Android自带的非常有用而且使用简单的工具,可以帮助我们更好地检视和设计用户界面(UI),绝对是UI检视的利器,下面来详细介绍如何在Android Studio开发环境下使用Hierarchy Viewer。

如何在Android Studio开发环境下使用HierarchyViewer

1.启动模拟器,通过模拟器运行你的应用

※HierarchyViewer是无法连接真机进行调试
 
布局文件如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="com.why.project.confirmcanceldialogdemo.MainActivity"> <Button
android:id="@+id/btn_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确定对话框"/> <Button
android:id="@+id/btn_confirmcancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确定取消对话框"/> <Button
android:id="@+id/btn_confirmcancelbetween"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确定取消保存对话框"/> <Button
android:id="@+id/btn_notitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="没有标题的对话框"/> <Button
android:id="@+id/btn_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="内容很多的对话框"/> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ConfirmCancelDialog" />
</LinearLayout>

2.打开Android Device Monitor

APP先运行起来再使用Android Device Monitor

依次点击菜单Tools>Android>Android Device Monitor,如下图:

3.进入Android Device Monitor界面,打开HierarchyViewer

4.加载出当前Activity的节点,可选中进行分析

附录1 将Tree View保存成图片

附录2 显示每个View节点的性能指标(颜色点)以及Measure、Layout、Draw的耗时的耗时

 选中某一个View,然后点击色板图标

参考资料:

Android Studio下HierarchyViewer的使用

在Android Studio下使用Hierarchy Viewer

AndroidStudio中如何打开hierarchyviewer

Android Studio下HierarchyViewer的使用的更多相关文章

  1. Android studio下gradle Robolectric单元测试配置

    android studio下gradle Robolectric单元测试配置 1.Robolectric Robolectric是一个基于junit之上的单元测试框架.它并不依赖于Android提供 ...

  2. Android studio 下JNI编程实例并生成so库

    Android studio 下JNI编程实例并生成so库 因为公司需要为Android相机做美颜等图像后期处理,需要使用JNI编程,最近学了下JNI,并且在Android Studio下实现了一个小 ...

  3. Android Studio下打jar包

    在我们使用Eclipse时,我们常常使用的第三方类库文件大多都是jar包形式,用起来很方便.但是jar包只能打包class文件,对于Android UI类库而言,我们常常需要打包资源文件,对于界面不多 ...

  4. Android Studio下导出jar包和aar包

    Android Studio下导出jar包和aar包 jar包和aar包的区别 步骤 1. 创建Android工程 创建工程比较简单,不错复述 2. 创建一个Library(Module) 创建了一个 ...

  5. Android Studio下多渠道打包

    Android Studio下实现多渠道打包 直接上步骤 步骤 1. 清单文件添加属性(以友盟统计为例) 在application标签下添加meta-data属性 <application -- ...

  6. Android Studio下使用NDK的流程

    我要重新拿回持之以恒徽章!! 老规矩,先说看能学会什么:ANDROID STUDIO下NDK的使用方法.JNI的基本使用方法,C语言调用JAVA的方法. 首先要下载NDK,如果你没有VPN可以来htt ...

  7. Android studio 下 JNI 开发实例

    在AS中进行 NDK 开发之前,我们先来简单的介绍几个大家都容易搞懵的概念: 到底什么是JNI,什么是NDK? 何为“交叉编译”? 先看什么是 JNI?JNI 的全称就是 Java Native In ...

  8. Android Studio下添加assets目录

    Android Studio下添加assets目录 分类: Android Studio2013-11-06 18:09 10872人阅读 评论(2) 收藏 举报 android studioasse ...

  9. Android Studio下jni应用

    最近在将一个小应用从eclipse开发迁移到android studio,程序中有native代码实现,在eclipse是靠Android.mk这么个mk文件来组织编译的,但到android stud ...

随机推荐

  1. VMware Workstation 虚拟机使用无线wifi上网配置

    VMware Workstation 虚拟机使用无线wifi上网配置 参考文档: 转载/VMware Workstation环境下的Linux网络设置/适用于无线网络 VMware Workstati ...

  2. 别人的Linux私房菜(22)软件安装:源代码与Tarball

    执行make,会在当前目录查找makefile文本文件(记录了源代码如何编译的详细信息). 内核相关的函数信息放置在/usr/lib./usr/lib64里. 在Tarball(一般为xxx.tar. ...

  3. python Strip函数和Split函数的用法总结 (python2.0,但用法与3.0是差不多的)

    strip函数原型 声明:s为字符串,rm为要删除的字符序列. 只能删除开头或是结尾的字符或是字符串.不能删除中间的字符或是字符串. s.strip(rm)        删除s字符串中开头.结尾处, ...

  4. 支持向量机(SVM)利用网格搜索和交叉验证进行参数选择

    上一回有个读者问我:回归模型与分类模型的区别在哪?有什么不同,我在这里给他回答一下 : : : : 回归问题通常是用来预测一个值,如预测房价.未来的天气情况等等,例如一个产品的实际价格为500元,通过 ...

  5. Swagger2基本注解使用

    @Api:用在请求的类上,表示对类的说明 tags="说明该类的作用,可以在UI界面上看到的注解" value="该参数没什么意义,在UI界面上也看到,所以不需要配置&q ...

  6. 阿里云远程连接CentOS

    1.购买一个CentOS的ECS服务器: 2.修改安全组,开放SSH/22的端口号: 这里是22/22为SSH连接的端口号:3389为远程桌面的默认端口号 3.利用xshell或者SecureCRT连 ...

  7. 2019.03.09 codeforces833B. The Bakery(线段树优化dp)

    传送门 线段树优化dpdpdp入门题. 要求把nnn个数分成kkk段,每段价值为里面不相同的数的个数,求所有段的价值之和最大值.n≤35000,k≤50n\le35000,k\le50n≤35000, ...

  8. SpringBoot+Mybatis配置Pagehelper分页插件实现自动分页

    SpringBoot+Mybatis配置Pagehelper分页插件实现自动分页 **SpringBoot+Mybatis使用Pagehelper分页插件自动分页,非常好用,不用在自己去计算和组装了. ...

  9. Educational Codeforces Round 58 (Rated for Div. 2) F dp + 优化(新坑) + 离线处理

    https://codeforces.com/contest/1101/problem/F 题意 有n个城市,m辆卡车,每辆卡车有起点\(s_i\),终点\(f_i\),每公里油耗\(c_i\),可加 ...

  10. Redis各种数据类型的应用场景

    redis是一种key values形式的非关系型数据库,通过内存存储,也可以把数据持久化到本地文件中. redis支持丰富的数据类型,String,list,set,zset,hash,下面说一下各 ...