什么是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. C#写入Oracle 中文乱码问题

    这个问题是我刚踏入工作觉得最坑的一个问题,找了很多方法.也问过不少人,但还是没能解决,偶然间返现了新大陆.... 具体问题描述是这样的: 我可以读取Oracle数据库中已有的中文内容,并能正确显示(O ...

  2. nginx常用服务配置

    一.nginx.conf的配置方式,创建新vhost user nginx; worker_processes ; worker_cpu_affinity ; worker_rlimit_nofile ...

  3. MFC改变坐标系

    1.在MainFrm中的PreCreateWindow中设置默认窗口大小 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !C ...

  4. Problem creating zip: Execution exce ption (and the archive is probably corrupt but I could not delete it): Java heap space -> [Help 1]

    今天mvn编译的时候报错:  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:s ...

  5. vue-element 动态单选多选全选

    实现效果如图 数据格式如下: pps: [{"code":"6","createTime":"2018-09-07 00:00:0 ...

  6. java 幂等性(转)

    (转自)http://www.cnblogs.com/weidagang2046/archive/2011/06/04/idempotence.html 理解HTTP幂等性 基于HTTP协议的Web ...

  7. Python 处理 json

    Python在处理json数据中有四个重要的函数:dump,load:dumps,loads. 序列化(dict 包装成 json文件) dump(转储):将字典dic对象 转化为 json文件 AP ...

  8. ie9 css文件大小限制

    使用webpack生成CSS对于一些有趣的定义很有趣.不幸的是,当你拥有一个大型应用程序并且需要IE9支持时,乐趣就会停止,因为IE9会忽略你生成的CSS包中的大于4000个选择器的部分.解决方案是将 ...

  9. 在windows系统安装pygame项目

    STEP1: 下载安装程序 访问https://bitbucket.org/pygame/pygame/downloads/,查找与你运行的Python版本匹配的安装程序,如果找不到,可以去https ...

  10. 换PHP7后访问Apache虚拟站点Forbidden的问题解决

    Httpd.conf中,注释掉前2行,补上后2行 <Directory /> #AllowOverride none #Require all denied Order deny,allo ...