这一节我们来看看登陆页面如何布局。对于刚接触到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_width:表示控件相对于父容器的宽度。

有三个值 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   用来指控件在父控件中的位置





.Net程序猿玩转Android开发---(3)登陆页面布局的更多相关文章

  1. .Net程序猿玩转Android开发---(11)页面跳转

    在不论什么程序开发中,都会遇到页面之间跳转的情况,Android开发也不例外.这一节,我们来认识下Android项目中如何进行页面跳转.页面跳转分为有參数和无參数页面跳转,已经接受还有一个页面的返回值 ...

  2. .Net程序猿玩转Android开发---(7)相对布局RelativeLayout

                 相对布局RelativeLayout是Android布局中一个比較经常使用的控件,使用该控件能够布局出适合各种屏幕分辨率的布局,RelativeLayout採用相对位置进行 ...

  3. .Net程序猿玩转Android开发---(8)表格布局TableLayout

    表格布局TableLayout是Android中比較经常使用的一个布局控件,既然是表格,肯定有行和列,TableLayout中的行有TableRow组成.列依据每行控件的数量来确定 假如第一行有3个控 ...

  4. .Net程序猿玩转Android开发---(6)线性布局LinearLayout

                                LinearLayout控件是Android中重要的布局控件,是一个线性控件,所谓线性控件的意思是指该控件里面的内容仅仅能水平或垂直排列.也就 ...

  5. .Net程序猿乐Android开发---(4)注册页面布局

    接下来我们介绍的登陆页面布局,在本节中,我们看一下注册页面布局,页面布局大同小异,来一起熟悉下基本控件的使用方法. 效果图: 1.加入注冊页面 右键选中layout目录,加入注冊页面.例如以下图 点击 ...

  6. .Net程序员玩转Android开发--ListView单击事件

    public class ListViewClickActivity extends Activity {         private ListView lv;        SimpleAdap ...

  7. android 开发 简单的页面布局

    package com.example.test; import android.app.Activity; import android.os.Bundle; import android.view ...

  8. .Net程序员玩转Android系列之一~Java快速入门

    前言 前段时间受公司业务发展需要,探索性进入Android开发领域.一切从零开始,java基础,Java进阶,Android框架学习,Eclipse熟悉,最终到第一个即时通讯App完成,历经一个月的时 ...

  9. 作为一个程序员怎么通过android开发赚钱

    ​ 上面是一个程序员通过Android开发每天的收入,信则有! 自己学安卓差不多,有一年了.我本来是从事javaweb开发的,可能学习安卓上手会快点.其实安卓没有那难 .首先开发安卓程序,要有一个,开 ...

随机推荐

  1. vsftp 安装日志

    很早的一个日志了,从自家的QQ上,查看总不方便,搬家的. 安装完 centos后 安装vsftpd yum install vsftpd 安装伯克利数据库工具 yum install db4 db4- ...

  2. iOS扫描二维码(系统方法)

    步骤如下: 1.导入AVFoundation框架,引入<AVFoundation/AVFoundation.h> 2.设置一个用于显示扫描的view 3.实例化AVCaptureSessi ...

  3. Sql Xtype

    SQL Server xtype的介绍   在数据库内创建的每个对象(约束.默认值.日志.规则.存储过程等)在表中占一行.只有在 tempdb 内,每个临时对象才在该表中占一行.  列名 数据类型 描 ...

  4. JavaScript--Date函数

    1. Date函数 var now = new Date(); 获取当前日期对象 now对象->Date.prototype->Object.prototype 将一个字符串转换为Date ...

  5. StartCoroutine/StopCoroutineInvoke

    本文由博主(YinaPan)原创,转载请注明出处:http://www.cnblogs.com/YinaPan/p/Unity_Coroutine.html using UnityEngine; us ...

  6. 如何用angularjs制作一个完整的表格之四__自定义ng-model标签的属性使其支持input之外的html元素

    有的时候我们需要为非input类型的元素添加ng-model来实现双向的数据绑定,从而减少冗余代码,那么可以尝试一下的方式 例如:我页面中使用了contenteditable这个属性来实现用户可直接编 ...

  7. gulpfile的结构

    使用了      yargs     用于获取启动参数,针对不同参数,切换任务执行过程时需要,本项目中的useCache和useSess      path     不明,貌似是用来将某个目录中的文件 ...

  8. php 4.X与5.x版本构造函数区别与类的继承

    今天看ecshop源码的时候发现 构造函数是和类名一样,以前没接触过,一下子疑惑啦 HP4.x 版本: PHP 4.x 的构造函数名与类名相同.        注意:在子类里父类的构造函数不会自动执行 ...

  9. js 实现 C# 的 format 方法

    2014-11-08 12:18:51 更新,修复原形链方法被当作关键词的bug,其实之前是想用全局关键词的,不过还是算了,array里有太多单词了.                          ...

  10. 在PyQt4中使用matplotlib

    matplotlib作为Python中著名的数据可视化工具,其官网也提供了在PyQt4中使用的源码,这里举一个应用实例,以备不时之需. 1) 利用Qt Designer创建GUI界面 Demo的GUI ...