Android detailed layout analysis-from the root layout to the specific layout
One, analyze what the root layout of the Android program is, where we write the XML file to deploy to, Setcontentview (layout) is going on.
The tools in the Android SDK provide a tool for analyzing the hierarchy of programs: Hierarchyviewer.bat. In this tool, you can see the actual detailed layout of the program. Next, let's analyze, with the newly created project.
Second, open the Hierarchyviewer.bat tool and run a newly created project.
Second, what is the root layout of Android, or what is the root screen?
1. When you click on the root layout, a red area is displayed in the lower right corner, corresponding to the corresponding layout. You can see that when you click Phonewindow&decorview (Decorview is an inner class in the Phonewindow Class), the lower-right corner shows the full screen: the status bar (StatusBar), the Navigation Bar (toolbar), the Content bar ( Content). To know, this phonewindow&decorview is the root layout we're looking for.
Next, let's look at what it contains. Look, as you can see, when you click Actionbaroverlayout, the red area in the lower right corner contains the navigation bar and the content bar. The status bar is not included.
R.layout.activity_main layout is relationlayout layout, I put a textview and a button in it, in the picture can be clearly seen. The toolbar contains a TextView used to display the appname, and a Actionmenuview shows the hidden menu. This gives you a clear understanding of how our layout was arranged.
Here we can see that our Activity_main.xml file, the Setcontentview method, puts the XML file in the layout of an ID called content.
Three, we are in the mainactivity to test a bit.
Using the GetWindow method to get the Phonewindow class, Getdecorview get concrete Decorview class.
From Decorview can be assigned to view, Decorview is a visual component that is the root layout of the Activity window.
Print it with log to see if it is. You can see the tag in the log box. And Decorview's super class unexpectedly is framlayout is not very surprised.
This part of the knowledge is not much explained, but it is critical to understanding the overall layout. Come on!
Android detailed layout analysis-from the root layout to the specific layout