简体   繁体   English

android - 什么是视图层次结构?

[英]android - what is view hierarchy?

I'm studying android, of course I'm novice, I always read something like view hierarchy, so what exactly does this mean? 我正在学习android,当然我是新手,我总是阅读类似于视图层次结构的东西,那究竟是什么意思呢? what is view hierarchy? 什么是视图层次结构? eg 例如

// fragment's containing frame doesn't exist. //片段包含的框架不存在。 The fragment // may still be created from its saved state, but there is // no reason to try to create its view hierarchy because it // won't be displayed. 片段//可能仍然是从其保存状态创建的,但是//没有理由尝试创建其视图层次结构,因为它//将不会显示。 Note this is not needed -- we could // just run the code below, where we would create and return // the view hierarchy; 注意这不是必需的 - 我们可以//只运行下面的代码,我们将创建并返回//视图层次结构; it would just never be used. 它永远不会被使用。

http://developer.android.com/reference/android/app/Fragment.html http://developer.android.com/reference/android/app/Fragment.html

A View inside another View creates an hierarchy, the outer view becomes the parent of the inner view and the inner view is its child. View内的另一个视图创建层次结构,所述外角度的内视图的父和内视图是其子。 It's just nested views. 它只是嵌套的视图。

Here's an example: 这是一个例子:

在此输入图像描述

You'll want to read the docs on the View class, but essentially views can be children of certain other views. 您将要阅读View类上的文档,但实际上视图可以是某些其他视图的子视图。 You can nest views in complicated ways. 您可以以复杂的方式嵌套视图。 This whole structure of views is referred to as the view hierarchy. 整个视图结构称为视图层次结构。

http://i.stack.imgur.com/gN6AO.png Each view in a user interface represents a rectangular area of the display. http://i.stack.imgur.com/gN6AO.png用户界面中的每个视图代表显示的矩形区域。 A view is responsible for what is drawn in that rectangle and for responding to events that occur within that part of the screen (such as a touch event). 视图负责在该矩形中绘制的内容以及响应屏幕该部分内发生的事件(例如触摸事件)。 A user interface screen is comprised of a view hierarchy with a root view positioned at the top of the tree and child views positioned on branches below. 用户界面屏幕由视图层次结构组成,其中根视图位于树的顶部,子视图位于下面的分支上。 The child of a container view appears on top of its parent view and is constrained to appear within the bounds of the parent view's display area. 容器视图的子项显示在其父视图的顶部,并且约束显示在父视图的显示区域的边界内。 you can refer to this link : [ http://www.techotopia.com/index.php/Understanding_Android_Views,_View_Groups_and_Layouts_in_Android_Studio][1] 你可以参考这个链接:[ http://www.techotopia.com/index.php/Understanding_Android_Views,_View_Groups_and_Layouts_in_Android_Studio] [1 ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM