android布局分为两类 ViewGroup View
控件树
ViewGroup
在每个控件的顶部,都有一个viewParent
Ui界面架构图
Activity--->Window --->DecorView--->TitleView ContentView
Activity--->Window 每个activity都有一个window对象,在android中window对象通常有PhoneWindow来实现,PhoneWindow将一个DecorView设置为整个应用窗口的View
DecorView Decoview作为窗口界面的顶层视图,封装了一些窗口操作的方法
DecorView将要显示的具体内容呈现在了PhoneWindow上,在里面所有的View的监听事件,都是通过通过WindowMangerServic
来进行接收, 并通过Activity 对象来回调相应的onClickListener
TitleView .ContentView 在显示上DeovView将屏幕分成两部分,一个是TitleView 另一个是ContentView
ContentView是一个Id 为contentde Framelayout
activity_xml就是设置在这样大的一个framelayout里
标准视图树
视图树的第二层装载了一个LinearLayout,作为ViewGroup,这一层的布局结构会根据对应的参数设置不同的布局
requestWindowFeature(Window.FEATURE_NO_TITLE)来设置全屏显示,没有TitleView了
requestWindowFeature必须在setContentView() 之前调用
在代码中,当程序在onCrate()方法中调用setContentView方法后,AcitivityManangerService 回调onResume()
此时系统才会把整个Decorview添加到PhoneWindow中 并让其显示出来,完成整个界面 的绘制
去除title
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yifei.myapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"> //去除actionBar
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>