<TextView android:id="@+id/firstview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ff0000" android:text="第一個(gè)Textview" /> <TextView android:id="@+id/second" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00ff00" android:text="第二個(gè)textview" android:layout_toRightOf="@id/firstview" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00ff00" android:text="第三個(gè)textview" android:layout_below="@id/firstview" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00ff00" android:text="第四個(gè)" android:layout_alignRight="@id/second" android:layout_below="@id/second" />
以上包含相對(duì)布局中幾種簡(jiǎn)單的屬性,截圖如下
創(chuàng)新互聯(lián)為客戶提供專業(yè)的網(wǎng)站設(shè)計(jì)制作、成都做網(wǎng)站、程序、域名、空間一條龍服務(wù),提供基于WEB的系統(tǒng)開發(fā). 服務(wù)項(xiàng)目涵蓋了網(wǎng)頁設(shè)計(jì)、網(wǎng)站程序開發(fā)、WEB系統(tǒng)開發(fā)、微信二次開發(fā)、成都手機(jī)網(wǎng)站制作等網(wǎng)站方面業(yè)務(wù)。<TextView android:id="@+id/firstview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ff0000" android:text="hello" android:textSize="50sp" /> <TextView android:id="@+id/second" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#0000ff" android:text="view" android:layout_alignBaseline="@id/firstview" android:layout_toRightOf="@id/firstview" />
android:layout_alignBaseline="@id/firstview"
上面這行代碼是對(duì)其到基準(zhǔn)線的意思,什么是基準(zhǔn)線,基準(zhǔn)線就相當(dāng)于四線格中的第三條線。效果圖如下
如圖所示,那條綠色的線就是基準(zhǔn)線
與父空間邊緣對(duì)其
//android:layout_alignParentRight="true"
上一行代碼的屬性值只能為true或者false,因?yàn)橐粋€(gè)控件他只能有一個(gè)父控件
執(zhí)行該代碼之后,hello就會(huì)到達(dá)屏幕 的右側(cè)。
android:layout_centerInParent="true"http://出現(xiàn)在父控件的中央位置 android:layout_centerHorizontal="true"http://處于水平方向的中央位置上 android:layout_centerVertical="true"http://垂直方向的
Android4.2新特性
//android:layout_alignEnd="@id/firstview"http://對(duì)其控件的尾部或者start <TextView android:id="@+id/firstview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00ff00" android:text="hello" /> <TextView android:id="@+id/secondview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ff0000" android:layout_below="@id/firstview" android:layout_alignEnd="@id/firstview" android:text="abc" /> //android:layout_alignParentEnd="true"與父控件的尾部對(duì)其
Android登陸框布局
<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:padding="15dp" > <TextView android:id="@+id/lableView" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="登錄界面" android:gravity="center" /> <EditText android:id="@+id/usernameText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_below="@id/lableView" android:hint="username" /> <EditText android:id="@+id/passwordText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignRight="@id/usernameText" android:layout_alignLeft="@id/usernameText" android:layout_below="@id/usernameText" android:hint="password" android:inputType="textPassword" /> <Button android:id="@+id/cancelButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="取消" android:layout_below="@id/passwordText" android:layout_alignParentRight="true" /> <Button android:id="@+id/okButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@id/cancelButton" android:layout_toLeftOf="@id/cancelButton" android:text="確定" /> </RelativeLayout>
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
文章標(biāo)題:Android相對(duì)布局RelativeLayout詳解-創(chuàng)新互聯(lián)
網(wǎng)頁路徑:http://chinadenli.net/article8/djjpop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、網(wǎng)站設(shè)計(jì)、App設(shè)計(jì)、ChatGPT、手機(jī)網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容