基于android-2.3.3_r1源代码,跟踪一下App进程从主线程ActivityThread的main()方法开始的执行流程
使用布局文件如下
<?xml
version="1.0"encoding="utf-8"?>
<com.example.root.myapplication.MyFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.root.myapplication.MainActivity">
<com.example.root.myapplication.MyTextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello
World!"
android:background="@android:color/white"
android:textColor="@android:color/black"/>
</com.example.root.myapplication.MyFrameLayout>
使用FrameLayout和TextView是因为其measure()、layout()相对简单一些
执行流程如下