国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

淺析Android App的相對布局RelativeLayout

2019-12-12 06:31:21
字體:
來源:轉載
供稿:網友

一、什么是相對布局
相對布局是另外一種控件擺放的方式
相對布局是通過指定當前控件與兄弟控件或者父控件之間的相對位置,從而達到相對的位置

二、為什么要使用相對布局
相對于線性布局ui性能好

三、相對布局的兩組常用屬性
值為某個存在控件id:

(1)android:layout_below放在某個存在id控件的下邊緣(也就是當前控件的上邊對齊到某個id控件的下邊緣

(2)android:layout_above放在某個存在id控件的上邊緣(也就是當前控件的下邊緣對齊到某個id控件的上邊緣

(3)android:layout_toLeftOf 放在某個存在id控件的左邊(也就是當前控件的右邊對齊到某個id控件的左邊

(4)android:layout_toRightOf  放在某個存在id控件的右邊(也就是當前控件的左邊對齊到某個id控件的右邊)

(5)android:layout_alignLeft 當前的控件左邊緣對齊到某個存在的id控件的左邊緣

(6)android:layout_alignRigth 當前的控件右邊緣對齊到某個存在的id控件的右邊緣

(7)android:layout_alignTop 當前的控件上邊緣對齊到某個存在的id控件的上邊緣

(8)android:alignBottom 當前的控件下邊緣對齊到某個存在的id控件的下邊緣

1.對齊至控件的基準線
基準線是為了保證印刷字母的整齊而劃定的線
值為某個存在控件的id:
android:layout_alignBaseline

2.與父控件的四個邊緣對齊
值為true or  false:
(1)android:layout_aliginParentLeft 對齊到父控件的左邊
(2)android:layout_alignParentRight 對錢對齊到父控件的右邊
(3)android:layout_alignParentTop對齊到父控件的上邊
(4)android:layout_alignParentBottom 對齊到父控件的下邊

3.對齊至父控件的中央位置
值為 true or false:
(1)android:layout_centerInParent  對齊到父控件的最中央位置
(2)android:layout_layout_Horizontal 對齊到父控件水平方向中央的位置
(3)android:layout_centerVertical  對齊到父控件垂直方向中央的位置

4.android 4.2  Relativelayout布局的新屬性
值為某個存在控件的di:
(1)android:layout_alignStart 當前控件的起始位置對對齊到某個存在控件id的起始位置
(2)android:layout_alignEnd  當前控件的起始位置對對齊到某個存在控件id的對齊到終點位置

值為true or false:
(1)android:layout_alignParentStart  對齊到父控件的起始位置
(2)android:layout_alignParentEnd 對齊到父控件的終點位置

5.字體居中

android:gravity="center"
默認值:
android:hint="值"
andriod:inputType="textpassworld"

四、相對布局實例―登錄界面

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"   xmlns:tools="http://schemas.android.com/tools"   android:layout_width="match_parent"   android:layout_height="match_parent"   android:layout_margin="20dp"   tools:context=".MainActivity" >      <TextView      android:id="@+id/Txttitle"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignParentLeft="true"     android:gravity="center_horizontal"     android:layout_alignParentRight="true"     android:text="登錄界面"/>    <EditText     android:id="@+id/username"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignLeft="@id/Txttitle"     android:layout_alignRight="@id/Txttitle"     android:layout_below="@id/Txttitle"      android:layout_marginTop="20dp"     android:hint="username"/>   <EditText      android:id="@+id/password"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_below="@id/username"     android:layout_alignLeft="@id/username"     android:layout_alignRight="@id/username"      android:layout_marginTop="20dp"     android:hint="password"     android:inputType="textCapWords"/>  </RelativeLayout> 

2016423115552275.jpg (290×344)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 赣州市| 建阳市| 阿坝| 丘北县| 遂溪县| 双柏县| 微山县| 金乡县| 曲靖市| 庄浪县| 余庆县| 临湘市| 汉寿县| 兴和县| 阿尔山市| 富平县| 东方市| 分宜县| 西城区| 天水市| 胶南市| 台中县| 舒兰市| 德昌县| 乌拉特前旗| 留坝县| 承德县| 永仁县| 盖州市| 鄱阳县| 嘉黎县| 永川市| 太白县| 旬邑县| 三原县| 蕉岭县| 宜城市| 肇源县| 洮南市| 射洪县| 洪泽县|