導(dǎo)入color素材包
打開Res --> values --> 新建color.xml --> 將 “顏色-記事本” 中的內(nèi)容全部復(fù)制到該xml文件中箫攀,保存
一肠牲、線性布局
1.線性布局共有兩個(gè)方向:
垂直(vertical)
水平(horizontal)
決定是垂直還是水平的屬性是Orientation
①android:orientation="horizontal"(水平,不寫該語句靴跛,默認(rèn)為水平方向)
②android:orientation="vertical"(垂直)
同時(shí)將背景設(shè)置背景色缀雳,如果已導(dǎo)入color素材可直接調(diào)取顏色
android:background="" ?--> ?在雙引號(hào)內(nèi)Alt+/ ?--> ?雙擊@color/ ?--> ?選取顏色
二、常用控件
(一)TextView文本控件
1.邊距修改
①數(shù)值單位:
sp字體大小單位
dp其他數(shù)值單位
②邊距屬性
android:paddingBottom=“xxdp” ?底部邊距
android:paddingTop=“xxdp” ?頂部邊距
android:paddingLeft=“xxdp” ?左部邊距
android:paddingRight=“xxdp” ?右部邊距
2.位置
android:gravity=“ ?”
①放在底部
android:gravity="bottom"
②放在底部靠右
android:gravity="bottom|right" ? ? ? ?//注意:此處bottom與right中間為豎線“|”梢睛,不是斜線“/”
(二)EditText輸入文本控件
垂直線性布局+置于底部右側(cè)
線性布局+View控件小練
三肥印、RelativeLayout 相對(duì)布局
android:layout_toRightOf在指定控件的右邊
android:layout_toLeftOf在指定控件的左邊
android:layout_above在指定控件的上邊
android:layout_below在指定控件的下邊
android:layout_alignBaseline跟指定控件水平對(duì)齊
android:layout_alignLeft跟指定控件左對(duì)齊
android:layout_alignRight跟指定控件右對(duì)齊
android:layout_alignTop跟指定控件頂部對(duì)齊
android:layout_alignBottom跟指定控件底部對(duì)齊
android:layout_alignParentLeft是否跟父布局左對(duì)齊
android:layout_alignParentTop是否跟父布局頂部對(duì)齊
android:layout_alignParentRight是否跟父布局右對(duì)齊
android:layout_alignParentBottom是否跟父布局底部對(duì)齊
android:layout_centerVertical在父布局中垂直居中
android:layout_centerHorizontal在父布局中水平居中
android:layout_centerInParent在父布局中居中