Android開發登陸界面布局

fmms 12年前發布 | 48K 次閱讀 Android Android開發 移動開發

Android開發登陸界面布局

        如果上圖所示,就是簡單的登錄界面了。andord的布局真的是,真的是,哪個。難以掌握的東西,哈,不過一旦了解深入點,又讓人爽的不行,流式布局總是比起windows mobile的絕對布局簡單而且容易控制。我是越來越傾向于流式布局的方式了,它的一點好處是適應設備時比較靈巧,wm使用了自適應dpi的方式,哪叫一個復雜啊,切不易于控制。

        布局的屬性 android:layout_width="fill_parent" ,指示了填充父區域,就是父容器有多大空間,就填充多大空間。android:layout_width="wrap_content",指示了它本身需要多大空間,就像父容器索取多大的空間,怎么說呢,就是它有多胖就占多大空。而哪個fill_parent就是不胖也全占滿了。
        再說android:layout_weight="0.1",這個weight(重量)是個很有意思的東西。可為一個父容器的 “子控件們”設置這個重量屬性,父容器根據這個重量的多少擇情分給這些子控件們多大空間。同時這個屬性還與子控件 寬高屬性的顯示(fill_parent 或者wrap_content)模式有關。

    

代碼如下:

  <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="@drawable/images1"
      >

   <LinearLayout android:id="@+id/LinearLayout01"
    android:layout_width="fill_parent"
    android:layout_weight="0.9"
    android:layout_height="fill_parent">
    </LinearLayout>
   <LinearLayout android:layout_width="fill_parent"
    android:id="@+id/LinearLayout02"
    android:layout_weight="0.1"
    android:orientation="vertical"
    android:layout_height="fill_parent">
      <LinearLayout android:id="@+id/LinearLayout03" android:layout_width="wrap_content" android:layout_height="wrap_content"></LinearLayout>
  <LinearLayout
      android:layout_marginLeft="10px"
      android:layout_marginRight="10px"
      android:gravity="center"
      android:layout_width="fill_parent"
      android:id="@+id/LinearLayout_account"
      android:orientation="horizontal"
      android:layout_height="wrap_content">

        <TextView android:textSize="12pt" android:id="@+id/lblAccount"
         android:text="@string/accountName"
         android:layout_weight="0.75"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"></TextView>
       
        <EditText
        android:layout_weight="0.25"
         android:layout_width="fill_parent"
        android:text="mailto:%22&nbsp;%20android:id=%22@+id/editBoxAccount" android:layout_height="wrap_content"></EditText>

      </LinearLayout>

  <LinearLayout
      android:layout_marginLeft="10px"
      android:layout_marginRight="10px"
      android:gravity="center"
      android:layout_width="fill_parent"
      android:orientation="horizontal"
      android:layout_height="wrap_content">

        <TextView android:textSize="12pt" android:id="@+id/lblPassword"
         android:text="@string/password"
         android:layout_weight="0.75"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"></TextView>

        <EditText
        android:layout_weight="0.25"
         android:layout_width="fill_parent"
         android:password="true"
        android:text="mailto:%22&nbsp;%20android:id=%22@+id/editBoxPassword" android:layout_height="wrap_content"></EditText>

      </LinearLayout>

      <LinearLayout
      android:layout_marginLeft="10px"
      android:layout_marginRight="10px"
      android:gravity="center"
      android:layout_width="fill_parent"
      android:orientation="horizontal"
      android:layout_height="wrap_content">

     <Button android:text="登錄"
     android:textSize="9pt"

     android:id="@+id/btnLogin" android:layout_width="fill_parent"
     android:layout_height="wrap_content"></Button>

      </LinearLayout>
  </LinearLayout>
  </LinearLayout>

 本文由用戶 fmms 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!