Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android - what is view hierarchy?

Tags:

android

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? e.g.

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

like image 648
user2580401 Avatar asked Aug 01 '13 20:08

user2580401


People also ask

What is a view hierarchy?

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.

What is view and view group in android?

View is a basic building block of UI (User Interface) in android. A view is a small rectangular box that responds to user inputs. Eg: EditText, Button, CheckBox, etc. ViewGroup is an invisible container of other views (child views) and other ViewGroup. Eg: LinearLayout is a ViewGroup that can contain other views in it.

What are different types of android views?

Android Layout Types TableLayout is a view that groups views into rows and columns. AbsoluteLayout enables you to specify the exact location of its children. The FrameLayout is a placeholder on screen that you can use to display a single view. ListView is a view group that displays a list of scrollable items.


3 Answers

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:

enter image description here

like image 81
Androiderson Avatar answered Sep 22 '22 09:09

Androiderson


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.

like image 23
kabuko Avatar answered Sep 22 '22 09:09

kabuko


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]

like image 45
Abderazak Amiar Avatar answered Sep 23 '22 09:09

Abderazak Amiar