最近開始學Android了,因爲是在B站上看的視頻教程,之後有東西忘了再學起來很麻煩,所以打算先把學到的一些東西寫下來,之後再查起來應該就會方便點了。android
android:layout_width
& android:layout_height
:佈局的寬和高,通常不用改,參數選 match_parent 就行佈局
android:background
:設置背景code
android:gravity
:設置重心,也就是子組件會往哪裏靠,好比若是參數是 center 的話,全部的組件都會在中間排列,其它同理。能夠同時使用多個參數,用 | 分割,如 right|bottom
即是設置爲右下角視頻
android:ignoreGrivaty
:設置哪些組件不須要遵循上面設置的 gravity ,參數是子組件的 id教程
android:padding
&android:paddingBottom
&android:paddingRight
&android:paddingLeft
&android:paddingTop
:設置組件的內邊距,即該組件的子組件距離該組件邊框的距離,既可用於設置佈局管理器,也可用於設置組件it
android:layout_margin
:設置組件的外邊距,相應的還有android:layout_marginTop
/android:layout_marginBottom
/android:layout_marginLeft
/android:layout_marginRight
分別用於設置上下左右的外邊距,既可用於設置佈局管理器,也可用於設置組件io
顧名思義,裏面全部的元素的位置都是相對的。
教程裏提到的參數有十五個,但要注意都是佈局中子組件的參數而不是佈局自己的參數。class
android:layout_above
&android:layout_below
&android:layout_toLeftOf
&android:layout_toRightOf
:參數爲其它組件的 id ,設置該組件位於對應 id 的組件外部的上下左右layout
android:layout_alignParentBottom
&android:layout_alignParentTop
&android:layout_alignParentRight
&android:layout_alignParentLeft
:參數爲 ture ,設置組件位於父組件的上下左右位置margin
android:layout_alignBottom
&android:layout_alignTop
&android:layout_alignRight
&android:layout_alignLeft
:參數爲其它組件的 id ,設置該組件位於對應 id 的組件內部的上下左右位置
android:layout_centerHorizontal
&android:layout_centerParent
&android:layout_centerVertical
:參數應該也爲 true ,設置該組件水平居中、佈局正中間、豎直居中
全部組件都是線性排布。
android:orientation
:參數爲 horizontal 則該佈局管理器爲水平佈局管理器,參數爲 vertical 則爲垂直線性佈局管理器
子組件參數:
android:layout_weight
:設置子組件的權重(分配剩餘空間用),用了這個參數的話大概就會充分佔據剩餘空間,填滿一整行或者一整列
顧名思義,全部組件是一幀幀層疊排布的,有點像 PS 裏圖層的概念。一般用於顯示層疊的內容,還能夠實現拖動效果。
android:foreground
:爲幀佈局管理器設置前景圖像(前景圖像指始終位於最上層的圖像)
android:foregroundGravity
:設置前景圖像的位置
以行和列的方式管理子組件的佈局管理器。經過<TableRow>
標籤設置一行,標籤對中每添加一個組件則爲行中的一列。若是不用<TableRow>
標籤則一個組件佔一行。
android:collapseColumns
:設置哪些列被隱藏,參數爲列的序號,從零開始計,多個序號間用逗號分隔
android:stretchColumns
:設置哪些列能夠被拉伸,參數同上。設置了這個參數的話一行將會被填滿,效果和上面線性佈局管理器的android:layout_weight
挺像的,可是要注意,這個是佈局管理器的參數,不是子組件的參數,而且是同時控制全部行的
android:shrinkColumns
:設置哪些列能夠被壓縮,參數同上。當一行顯示不下全部組件時,該參數設置的列將會被壓縮
與表格佈局管理器的區別在於,表格只能跨列,網格則是行和列均可以跨。同時表格一行顯示不下會跑到屏幕外面去,網格則會(在達到設置的最大列數後)自動換行。
android:columnCount
:設置最大列數
android:rowCount
:設置最大行數
android:oritentation
:設置水平仍是豎直,和線性佈局管理器同樣
子組件參數:
android:layout_grivaty
:設置子組件位於網格空間的何處
android:layout_cloumn
&android:layout_row
:設置子組件位於第幾列/第幾行,參數爲行或列的序號(整數)
android:layout_cloumnSpan
&android:layout_rowSpan
:設置子組件跨幾列/幾行,參數爲一個整數,搭配android:layout_grivaty="fill"
可使子組件填充滿這幾行/幾列空間
android:layout_columWeight
&android:layout_rowWeight
:設置子組件列與行的權重