Android執行個體-手機安全衛士(六)-製作功能區(設定中心)UI介面

來源:互聯網
上載者:User

標籤:

一、目標。

  製作類似手機設定中的效果。

二、代碼實現。

  1、整體採用線性布局,最上面是一個TextView,下面一個採用相對布局,並設定該相對布局的與邊緣的位移量。

  2、在相對布局中存在4個組件:2個TextView、1個CheckBox和1條直線。

  3、直線的畫法:採用<View.../>控制項,設定高度為“0.1dip”(該值的大小決定線的粗細),背景顏色為黑色(背景顏色就是線的顏色),其他屬性如寬度等跟其他空間一樣正常設定。

代碼如下:

 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3     android:layout_width="match_parent" 4     android:layout_height="match_parent" 5     android:orientation="vertical" > 6  7     <TextView 8         android:layout_width="match_parent" 9         android:layout_height="50dip"10         android:background="#00ffff"11         android:gravity="center"12         android:text="設定中心"13         android:textColor="#000000"14         android:textSize="26sp" />15 16     <RelativeLayout17         android:layout_width="wrap_content"18         android:layout_height="wrap_content"19         android:layout_marginLeft="10dip"20         android:layout_marginRight="10dip" >21 22         <TextView23             android:id="@+id/setting_update_title"24             android:layout_width="wrap_content"25             android:layout_height="wrap_content"26             android:layout_marginTop="10dip"27             android:text="自動更新"28             android:textColor="#000000"29             android:textSize="22dip" />30 31         <TextView32             android:id="@+id/setting_update_content"33             android:layout_width="wrap_content"34             android:layout_height="wrap_content"35             android:layout_below="@id/setting_update_title"36             android:text="允許軟體連網時自動更新"37             android:textColor="#88000000"38             android:textSize="18dip" />39 40         <CheckBox41             android:id="@+id/setting_update_checkbox"42             android:layout_width="wrap_content"43             android:layout_height="wrap_content"44             android:layout_alignParentRight="true"45             android:layout_centerVertical="true"/>46         <View 47             android:layout_below="@id/setting_update_content"48             android:layout_width="match_parent"49             android:layout_height="0.1dip"50             android:layout_marginTop="2dip"51             android:background="#70000000"/>52         53     </RelativeLayout>54 55 </LinearLayout>
View Code

Android執行個體-手機安全衛士(六)-製作功能區(設定中心)UI介面

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.