gzggyy

  如果上图所示,就是简单的登录界面了。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>

分类:

技术点:

相关文章:

  • 2021-11-30
  • 2021-09-02
  • 2022-12-23
  • 2021-11-30
  • 2022-02-06
  • 2021-10-14
  • 2021-06-25
猜你喜欢
  • 2021-11-30
  • 2022-02-07
  • 2022-01-05
  • 2021-08-06
  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
相关资源
相似解决方案