在做參數(shù)設置時我們需要實現(xiàn)一小塊區(qū)域的文字加上復選框或單選框,讓用戶設置參數(shù),在一個頁面上有多個參數(shù)要設置,那就需要多個區(qū)域,如圖所示,像這樣的布局我們一般怎么實現(xiàn)呢?接下來由百恒網(wǎng)絡工程向大家介紹,線性布局(linearlayout)與相對布局(relativelayout)結(jié)合使用方法。
1.我們先看一個簡單的相對布局(relativelayout)。
?
? ? android:layout_width="match_parent"
? ? android:layout_height="100dp" ??
? ? android:background="#000000"
? ? tools:context="cn.jxbh.commonlayout.MainActivity" >
? ?
? ? ? ? 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: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: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_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_height="100dp" >
? ?
? ? ? ? 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: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: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_marginTop="10dp"
? ? ? ? android:layout_width="match_parent" ?
? ? ? ? android:layout_height="1dp" ?
? ? ? ? android:background="#88ffffff" ?
? ? ? ? />
? ? ? ?
? ? ? ?
? ? android:layout_height="80dp" >
? ?
? ? ? ? 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: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: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_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ì)服務是我們始終的追求.