简体   繁体   中英

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? 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

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. 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. 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. 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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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