zoukankan      html  css  js  c++  java
  • .Net程序猿玩转Android开发---(3)登陆页面布局

                            这一节我们来看看登陆页面如何布局。对于刚接触到Android开发的童鞋来说。Android的布局感觉比較棘手。须要结合各种属性进行设置,接下来我们由点入面来

    了解安卓中页面如何布局,登陆页面非常easy,两个文本框和一个button,页面效果例如以下:

                           

                1.布局代码

                           点击activity_mail.xml能够查看布局代码

                           点击graphical Layout切换到设计窗口

                            所有代码

                            

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
     
      <LinearLayout android:layout_width="fill_parent"  android:layout_weight="0.9" android:layout_height="fill_parent">
        </LinearLayout>
    
    
    
       <LinearLayout 
      android:layout_width="fill_parent"
      android:layout_weight="0.1"
      android:orientation="vertical"
      android:layout_height="fill_parent">
    
        
        
      <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="8pt"
        android:text="username"
        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="请输入username"
         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="8pt" 
            android:text="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="请输入password" 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:layout_width="fill_parent"    android:layout_height="wrap_content">   </Button>
          </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:layout_width="fill_parent"    android:layout_height="wrap_content">   </Button>
          </LinearLayout>
    
    
    
      </LinearLayout>
        
    </LinearLayout>


                2. 属性说明

                              控件介绍

                                    LinearLayout控件: 线性布局控件 ,顾名思义就是以线性方式展示。包含横向和总向两种线性方式

                                      android:orientation="vertical"表示垂直方向。android:orientation="horizontal"表示水平方向

                                    TextView控件:显示控件。类似于label标签控件

                                    EditText控件:文本框控件,类似于TextBox控件

                                   Buttonbutton控件

                              属性说明

                                layout_表示控件相对于父容器的宽度。

    有三个值 fill_parent   wrap_content  match_parent

                                 fill_parent 表示填充整个屏幕宽度

                                 wrap_content 表示匹配文字的宽度

                                 android:orientation="vertical" 设置水平和垂直方向

                                 android:orientation="vertical"  设置控件左边距

                                 android:layout_weight 设置控件所占的百分比

                                 android:gravity="center"  设置控件内的元素位置

                                  android:layout_gravity   用来指控件在父控件中的位置

                                 

    
    
    
  • 相关阅读:
    执行脚本,且以脚本名保存log
    循环读取寄存器(QSFP-DD)并且分别保存log
    shell脚本添加脚本执行时间和当前运行次数current running time
    软件后门种植
    IPC$管道的利用与远程控制
    古典密码-维吉尼亚密码实验
    古典密码之乘法密码
    古典密码之凯撒密码
    密码破解工具Brutus
    ASPack壳脱壳实验
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/5276940.html
Copyright © 2011-2022 走看看