[Reprinted] hierarchyview. bat, a powerful tool for learning Android Interface Design

Source: Internet
Author: User
Problems: 
I see other people's programs, want to learn how people's UI layout is done, how can I snoop into one or two?
Problems: 
When learning viewgroup and layout, we may have a question. If I do not place layout in the XML layout file or directly place textview or other components, how does it layout?
Solution:
The android SDK comes with a tool for viewing the hierarchical structure of the UI layout: hierarchyview. bat. When the simulator runs, this tool can be used to display the UI components in the current activity in the form of an object tree, and the attributes contained by each component can also be snooped. Any node on the object tree can see the display effect of this node and the following nodes. With hierarchyview, You can thoroughly understand XML layout files and learn other excellent layout skills.


(I didn't see the inconspicuous hierachyview. BAT file. Ah, it turned out to be a powerful tool for learning Android interface design)

Usage: After the simulator and the program you want to observe are started, double-click hirerachyview. BAT and click load view hierarchy.


Now let's solve the first problem: Analysis of androidqq login interface composition.
You can see that the core part of the QQ logon interface is placed in relative layout, and even some textviews use the ID automatically generated by IDE: textview01.
Next we will solve the second problem: Find the default layout method?
Let's create a new project with only one textview in Main. xml,
<? XML version = "1.0" encoding = "UTF-8"?>
<Textview Android: text = "hi" Android: Id = "@ + ID/TV"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
Xmlns: Android = "http://schemas.android.com/apk/res/android"> </textview>

Let's see what the layout levels are like:


We can see that the top-level element is a phonewindow with a linear layout of linearlayout and an application title bar below,

A title bar consists of a frame layout framelayout and a textview.
The textview we write is also placed in a layout. This layout is the framelayout of content.
Next, we will create a program with linearlayout. Let's take a look at its hierarchy to determine whether the ID is inherent in the framelayout of content or because no layout elements are automatically added by the system.
<? XML version = "1.0" encoding = "UTF-8"?>
<Linearlayout Android: Id = "@ + ID/linearlayout01"
Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"
Xmlns: Android = "http://schemas.android.com/apk/res/android">
<Textview Android: text = "Haha" Android: Id = "@ + ID/textview01"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"> </textview>
</Linearlayout>
The following is the UI hierarchy of the new program: This time we also saw that the ID is framelayout of content. This shows that it is inherent in the window layout structure.
From: Android Learning Guide

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.