VIEWS
在屏幕上展示內(nèi)容的視圖
所有VIEW組合起來的叫布局(layout)
所有布局組合成用戶界面(UI)
- TextView文字
- ImageView圖片
- Button按鈕
命名法 Camel Case (駝峰命名法)

XML
標(biāo)簽
<TextView
……
…… /> 自閉標(biāo)簽
</TextView> 打開標(biāo)簽
……
</TextView> 關(guān)閉標(biāo)簽
如果沒有子標(biāo)簽,則用自閉標(biāo)簽
如果有子標(biāo)簽,則用打開標(biāo)簽 + 關(guān)閉標(biāo)簽,如
<LinearLayout>
<TextView
…… />
</LinearLayout>
<TextView
android:text="Happy Birethday!"
android:background="@android:color/darker_gray"
android:layout_width="150dp"
android:layout_height="75dp"/>
屬性名 = "屬性值"
dp(密度無關(guān)像素)
用于描述view的尺寸,在物理尺寸上相同,但是會被映射到不同數(shù)量的像素
可接觸目標(biāo)(如按鈕)長和寬至少是48dp
Debug
- 查閱錯誤信息
- 用正常運行的樣例代碼對照,找出問題
(對照Common Android Views Cheat Sheet)
使用撤銷
尋求幫助
view 寬高
android:layout_width="wrap_content"
android:layout_width="wrap_content"
隨內(nèi)容變化寬高
sp (與dp一樣,比例無關(guān)像素)
用于描述字體大小
字體設(shè)置規(guī)范參考 Google Material Design
不知道該用什么sp的時候,可以使用默認(rèn)的 small ,medium , large
android:textAppearance="?android:textAppearanceSmall"
android:textAppearance="?android:textAppearanceMedium"
android:textAppearance="?android:textAppearanceLarge"
color
可用android庫里的顏色,但是不齊全,
推薦使用十六進制的顏色,具體參考 Google Material Design
android:background="#2196F3"http://藍色
ImageView
<ImageView
android:src="@drawable/cake"
android:layout_width="wrap_content"
android:layout_width="wrap_content"
android:scaleType="center"/>
@ 表示在Android app里面引用資源,不需要申明引用的文件類型(png. jpeg)
scaleType 表示圖片在ImageView里是要放大或者縮小
遇到問題
單詞容易輸錯,找錯誤的時候找了半天,所以還是得小心小心,死記硬背
總結(jié)
查詢Android 官方文檔,可以找到TextView的新屬性
樣式只用三、四種貫穿始終,統(tǒng)一大小,顏色參考Google Material Design
希望一直這樣熱情下去,大家一起學(xué)習(xí),加油