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

<?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的耗时的耗时

参考资料:
Android Studio下HierarchyViewer的使用
在Android Studio下使用Hierarchy Viewer
AndroidStudio中如何打开hierarchyviewer
Android Studio下HierarchyViewer的使用的更多相关文章
- Android studio下gradle Robolectric单元测试配置
android studio下gradle Robolectric单元测试配置 1.Robolectric Robolectric是一个基于junit之上的单元测试框架.它并不依赖于Android提供 ...
- Android studio 下JNI编程实例并生成so库
Android studio 下JNI编程实例并生成so库 因为公司需要为Android相机做美颜等图像后期处理,需要使用JNI编程,最近学了下JNI,并且在Android Studio下实现了一个小 ...
- Android Studio下打jar包
在我们使用Eclipse时,我们常常使用的第三方类库文件大多都是jar包形式,用起来很方便.但是jar包只能打包class文件,对于Android UI类库而言,我们常常需要打包资源文件,对于界面不多 ...
- Android Studio下导出jar包和aar包
Android Studio下导出jar包和aar包 jar包和aar包的区别 步骤 1. 创建Android工程 创建工程比较简单,不错复述 2. 创建一个Library(Module) 创建了一个 ...
- Android Studio下多渠道打包
Android Studio下实现多渠道打包 直接上步骤 步骤 1. 清单文件添加属性(以友盟统计为例) 在application标签下添加meta-data属性 <application -- ...
- Android Studio下使用NDK的流程
我要重新拿回持之以恒徽章!! 老规矩,先说看能学会什么:ANDROID STUDIO下NDK的使用方法.JNI的基本使用方法,C语言调用JAVA的方法. 首先要下载NDK,如果你没有VPN可以来htt ...
- Android studio 下 JNI 开发实例
在AS中进行 NDK 开发之前,我们先来简单的介绍几个大家都容易搞懵的概念: 到底什么是JNI,什么是NDK? 何为“交叉编译”? 先看什么是 JNI?JNI 的全称就是 Java Native In ...
- Android Studio下添加assets目录
Android Studio下添加assets目录 分类: Android Studio2013-11-06 18:09 10872人阅读 评论(2) 收藏 举报 android studioasse ...
- Android Studio下jni应用
最近在将一个小应用从eclipse开发迁移到android studio,程序中有native代码实现,在eclipse是靠Android.mk这么个mk文件来组织编译的,但到android stud ...
随机推荐
- GitHub上高质量项目
scribejava/scribejava:一个简单的 Java 实现的 OAuth/OAuth2 库winterbe/java8-tutorial:绝对值得一看的Java8指南.教程javaee-s ...
- spring aop 切面编程中获取具体方法的方法
spring 切面编程中获取具体方法的方法 工作中,使用环绕通知,用来捕获异常,然后通过获取方法的返回值,返回不同的数据给到调用方. 由于方法的返回值不同,我们处理异常时,也需要返回不同的格式. 这时 ...
- python3 django1.11 安装xadmin 的方法,亲测可用
首先需要Pip安装如下的包ip install django-crispy-forms pip install django-import-export pip install django-reve ...
- weblogic获取应用目录路径(war包)
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletExcepti ...
- can't open the mysql.plugin table. please run mysql_upgrade to create it.
To initialize a fresh data directory, you basically (after setting your config file) just have to ru ...
- openXML向Word插入表
表是 Word 中的另一类型的块级内容,它是以行和列排列的一组段落(以及其他块级内容). Word 中的表格通过 tbl 元素定义,该元素类似于 HTML <表格>标记. 表元素指定文档中 ...
- robotframework 远程连接数据库问题
今天在使用RF远程连接数据库时出现报错的问题,因为我发现只安装databaselibrary跟PyMsql的话,连接本地的数据库是OK的,但是如果我们的测试机性能有限,那么既要编写代码.运行测试.还有 ...
- 记录一次Service被注入mapper实例的错误
在一个搭建框架为SSM的项目中,有一个需求是数据库更新同步Solr索引库的数据. 在使用ActiveMQ作为中间件,实现这个需求时却发生了一个错误. 在Listener实现类里我想注入一个Servic ...
- 如何利用Python实现自动打卡签到
需求描述 我们需要登录考勤系统(网页端,非手机端)进行签到,如果不想每天都早早起来打卡签到,就可以通过写程序实现这一功能. 业务梳理 通过长时间的早起打卡签到发现规律,我每天只是不停的点击,签到,都是 ...
- xx系统属性分析
在本周的课程学习当中,我们简单了解到系统的一些属性,同时在课下也对<大型网站技术架构:核心原理与案例分析>进行了初步的阅读. 在书籍中我看到了许多其他的知识,也对课堂学习的知识有了巩固,现 ...