我已經用一個Activity編寫了一個簡單的Hello World應用程序。當佈局未明確聲明時,Activity的默認佈局是什麼?
類:
public class HelloWorld extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.helloworld);
}
}
helloworld.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/hello"/>
我有所需的資源和 '的AndroidManifest.xml' 的地方,在應用程序運行正常。
在'hierarchyviewer'工具的'View Hierarchy window'中,我注意到TextView小部件的父代是FrameLayout,其父代是LinearLayout(爲了簡潔起見,我只剪切了所需的屏幕截圖)。屏幕截圖:
在我的 'helloworld.xml',我從來沒有宣佈的FrameLayout父爲TextView的部件。請幫助我理解:
1.通常,如果運行時未在佈局資源(xml文件)中明確聲明,運行時如何確定佈局?
2.在圖中,爲什麼LinearLayout是FrameLayout的父級?
非常感謝。