ADT爲我們提供了可視化佈局編輯器。(用可視化佈局編輯器不具有良好的屏幕適配性。)
Graphical Layout就是可視化佈局編輯器,xxx.xml是通過XML文件的方式來編輯佈局。
android:id是給當前元素定義一個唯一標識符,之後可以在代碼中對這個元素進行操作
>要在XML中引用一個id,就要使用@id/id_name這種語法
>要在XML中定義一個id,則要使用@+id/id_name這種語法。
android:layout_width指定當前元素的寬度
android:layout_height指定當前元素的高度
>match_parent表示讓當前元素和父元素一樣寬
>wrap_content表示讓當前元素的高度剛好包含裏面的內容
android:text指定元素中顯示的文字內容
android:gravity指定文字的對齊方式
>可選值有top、bottom、left、right、center等可以用“ | ” 來同時指定多個值。
>center等同於center_vertical|center_horizontal
android:textSize指定文字大小
android:textColor指定文字顏色
android:hint指定提示性文字
android:maxLines指定了EditText的最大行數爲,當輸入的內容超過最大行數時,文本就會向上滾動,而EditText則不會再繼續拉伸。
android:background
android:layout_margin
android:layout_marginLeft
android:layout_marginRight
android:layout_marginTop
android:layout_marginBottom
android:singleLine="true"是否單行顯示
android:ellipsize="end"當文本內容超出控件寬度時,文本的縮略方式
android:src="@drawable/xxx"設置某張圖片爲ImageView的內容
android:scaleType="fitXY"讓這張圖片拉伸填充滿整個控件大小