android界面线性布局

来源:互联网 发布:java程序员买书 编辑:程序博客网 时间:2024/05/21 17:33
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"//垂直排列
    android:background="@drawable/ic_launcher"
    tools:context=".Addressbook" >
<LinearLayout 
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:orientation="horizontal"//水平排列
   >
    <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="用户名"
        android:textSize="20sp"
        />
    <EditText 
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:hint="请输入用户名"
        android:inputType="textPersonName"
        />
</LinearLayout>
<LinearLayout 
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:orientation="horizontal"
   android:layout_marginTop="20dp"
   >
   <TextView 
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="密    码"
       android:textSize="20sp"
       />
   <EditText 
       android:layout_width="0dp"
       android:layout_weight="1"
       android:layout_height="wrap_content"
       android:hint="请输入密码"
       android:inputType="textPassword"
       />
</LinearLayout>
<LinearLayout 
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:orientation="horizontal"
   android:layout_marginTop="20dp"
   >
   <Button 
       android:layout_width="0dp"
       android:layout_weight="1"
       android:layout_height="wrap_content"
       android:text="登陆"
       android:textSize="20sp"
       />
   <Button 
       android:layout_width="0dp"
       android:layout_weight="1"
       android:layout_height="wrap_content"
       android:text="注册"
       android:textSize="20sp"
       />
</LinearLayout>
</LinearLayout>
0 0