Android 應用之最簡main.xml說明 <?xml version="1.0" encoding="utf-8"?> //指示這個文本文件是以XML格式描述的
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"//XML描述文件的名稱空間是後面的URL網址
android:layout_width="fill_parent" //填滿整個上層空間
android:layout_height="fill_parent" //填滿整個上層空間
android:orientation="vertical" > //這個界面的的版面配置方式是從上而下的垂直地排列其內含的界面組件
<TextView //顯示文本,可以設定為可編輯.TextView是一個完整的文本編輯器,基類被配置成為不可編輯
android:layout_width="fill_parent" //寬度值填滿LinearLayout整個界面
android:layout_height="wrap_content" //隨著文字字段行數的不同而改變TextView的高度
android:text="@string/hello" /> //顯示對應的文字
</LinearLayout>
關於TextView,請見:http://developer.android.com/reference/android/widget/TextView.html
Android內建的版面配置方式
名稱 | 配置方式 |
LinearLayout | 線性版面配置 |
FrameLayout | 框架版面配置 |
TableLayout | 表格版面配置 |
RelativeLayout | 相對位置版面配置 |
摘自 Alpha's Blog