最近中文字幕大全|熟女少妇精品一区二区|国产网红主播精品一区|日本一区二区精品理论电影|欧洲少妇无码精品视频在线|久久国产精品永久免费网站|人妻无码久久一区二区免费麻豆|国产日韩欧美一区二区在线高清

十二年專注于品牌網(wǎng)站建設 十余年專注于網(wǎng)站建設_小程序開發(fā)_APP開發(fā),低調(diào)、敢創(chuàng)新、有情懷!
南昌百恒網(wǎng)絡微信公眾號 掃一掃關(guān)注
小程序
tel-icon全國服務熱線:400-680-9298,0791-88117053
掃一掃關(guān)注百恒網(wǎng)絡微信公眾號
掃一掃打開百恒網(wǎng)絡微信小程序

百恒網(wǎng)絡

南昌百恒網(wǎng)絡

線性布局(linearlayout)與相對布局(relativelayout)的結(jié)合使用實例

百恒網(wǎng)絡 2014-10-20 15084

在做參數(shù)設置時我們需要實現(xiàn)一小塊區(qū)域的文字加上復選框或單選框,讓用戶設置參數(shù),在一個頁面上有多個參數(shù)要設置,那就需要多個區(qū)域,如圖所示,像這樣的布局我們一般怎么實現(xiàn)呢?接下來由百恒網(wǎng)絡工程向大家介紹,線性布局(linearlayout)與相對布局(relativelayout)結(jié)合使用方法。

1.我們先看一個簡單的相對布局(relativelayout)。

線性布局與相對布局實現(xiàn)參數(shù)設置實例

? ? ? xmlns:tools="http://schemas.android.com/tools"
? ? android:layout_width="match_parent"
? ? android:layout_height="100dp" ??
? ? android:background="#000000"
? ? tools:context="cn.jxbh.commonlayout.MainActivity" >

? ? ? ? ? ? android:id="@+id/tv1"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignParentLeft="true"
? ? ? ? android:layout_alignParentTop="true"
? ? ? ? android:layout_marginTop="14dp"
? ? ? ? android:textSize="20sp"
? ? ? ? android:textColor="#ffffff"
? ? ? ? android:text="About Baiheng"
? ? ? ? ?/>

? ? ? ? ? ? android:id="@+id/tv2"
? ? ? ? android:layout_width="240dp"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignParentLeft="true"
? ? ? ? android:layout_below="@+id/tv1"
? ? ? ? android:layout_alignLeft="@id/tv1"
? ? ? ? android:textSize="14sp"
? ? ? ? android:textColor="#88ffffff"
? ? ? ? android:text="Baiheng Software was founded in 2006, specializing in software development companies. detailed ..."
? ? ? ? />

? ? ? ? ? ? android:id="@+id/checkBox1"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignParentRight="true"
? ? ? ? android:layout_centerVertical="true" ? ??
? ? ? ? android:layout_marginRight="24dp"
? ? ? ? android:text="" />


相對布局(relative layout)實現(xiàn)實例
2.我們在線性布局中嵌套入相對布局,代碼如下。

? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? android:paddingBottom="@dimen/activity_vertical_margin"
? ? android:paddingLeft="@dimen/activity_horizontal_margin"
? ? android:paddingRight="@dimen/activity_horizontal_margin"
? ? android:paddingTop="@dimen/activity_vertical_margin" ??
? ? android:background="#000000"
? ? android:orientation="vertical" >

? ? ? ? android:layout_width="match_parent"
? ? android:layout_height="100dp" >
? ? ? ? ? ? android:id="@+id/tv1"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignParentLeft="true"
? ? ? ? android:layout_alignParentTop="true"
? ? ? ? android:layout_marginTop="14dp"
? ? ? ? android:textSize="20sp"
? ? ? ? android:textColor="#ffffff"
? ? ? ? android:text="About Baiheng"
? ? ? ? ?/>

? ? ? ? ? ? android:id="@+id/tv2"
? ? ? ? android:layout_width="240dp"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignParentLeft="true"
? ? ? ? android:layout_below="@+id/tv1"
? ? ? ? android:layout_alignLeft="@id/tv1"
? ? ? ? android:textSize="14sp"
? ? ? ? android:textColor="#88ffffff"
? ? ? ? android:text="Baiheng Software was founded in 2006, specializing in software development companies. detailed ..."
? ? ? ? />

? ? ? ? ? ? android:id="@+id/checkBox1"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignParentRight="true"
? ? ? ? android:layout_centerVertical="true" ? ??
? ? ? ? android:layout_marginRight="24dp"
? ? ? ? android:text="" />
? ?
? ? ? ? ? ? ? ? android:layout_below="@id/tv2"
? ? ? ? android:layout_marginTop="10dp"
? ? ? ? android:layout_width="match_parent" ?
? ? ? ? android:layout_height="1dp" ?
? ? ? ? android:background="#88ffffff" ?
? ? ? ? />
? ? ? ?
? ? ? ? ? ? android:layout_width="match_parent"
? ? android:layout_height="80dp" >
? ? ? ? ? ? android:id="@+id/tv1b"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignParentLeft="true"
? ? ? ? android:layout_alignParentTop="true"
? ? ? ? android:layout_marginTop="14dp"
? ? ? ? android:textSize="20sp"
? ? ? ? android:textColor="#ffffff"
? ? ? ? android:text="GPS satellites"
? ? ? ? ?/>

? ? ? ? ? ? android:id="@+id/tv2b"
? ? ? ? android:layout_width="260dp"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignParentLeft="true"
? ? ? ? android:layout_below="@+id/tv1b"
? ? ? ? android:layout_alignLeft="@id/tv1b"
? ? ? ? android:textSize="14sp"
? ? ? ? android:textColor="#88ffffff"
? ? ? ? android:text="Let apps use GPS to pinpoint your location"
? ? ? ? />

? ? ? ? ? ? android:id="@+id/checkBox1b"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignParentRight="true"
? ? ? ? android:layout_centerVertical="true" ? ??
? ? ? ? android:layout_marginRight="24dp"
? ? ? ? android:text="" />
? ?
? ? ? ? ? ? ? ? android:layout_below="@id/tv2"
? ? ? ? android:layout_marginTop="10dp"
? ? ? ? android:layout_width="match_parent" ?
? ? ? ? android:layout_height="1dp" ?
? ? ? ? android:background="#88ffffff" ?
? ? ? ? />


備注:

1.我們在此使用view加了兩條分隔線,可以通過調(diào)節(jié)高度來控制線的精細。

2.顏色值最前面兩位數(shù)是控制線的透明度,argb.

原創(chuàng)文章出自:百恒網(wǎng)絡 如轉(zhuǎn)載請注明出處!專業(yè),專注于南昌網(wǎng)站建設、南昌APP開發(fā),為用戶提供高品質(zhì)的網(wǎng)絡產(chǎn)品及優(yōu)質(zhì)服務是我們始終的追求.


400-680-9298,0791-88117053
掃一掃關(guān)注百恒網(wǎng)絡微信公眾號
掃一掃打開百恒網(wǎng)絡小程序

歡迎您的光顧,我們將竭誠為您服務×

售前咨詢 售前咨詢
 
售前咨詢 售前咨詢
 
售前咨詢 售前咨詢
 
售前咨詢 售前咨詢
 
售前咨詢 售前咨詢
 
售后服務 售后服務
 
售后服務 售后服務
 
備案專線 備案專線
 
×