.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_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)登陆页面布局的更多相关文章
- .Net程序猿玩转Android开发---(11)页面跳转
在不论什么程序开发中,都会遇到页面之间跳转的情况,Android开发也不例外.这一节,我们来认识下Android项目中如何进行页面跳转.页面跳转分为有參数和无參数页面跳转,已经接受还有一个页面的返回值 ...
- .Net程序猿玩转Android开发---(7)相对布局RelativeLayout
相对布局RelativeLayout是Android布局中一个比較经常使用的控件,使用该控件能够布局出适合各种屏幕分辨率的布局,RelativeLayout採用相对位置进行 ...
- .Net程序猿玩转Android开发---(8)表格布局TableLayout
表格布局TableLayout是Android中比較经常使用的一个布局控件,既然是表格,肯定有行和列,TableLayout中的行有TableRow组成.列依据每行控件的数量来确定 假如第一行有3个控 ...
- .Net程序猿玩转Android开发---(6)线性布局LinearLayout
LinearLayout控件是Android中重要的布局控件,是一个线性控件,所谓线性控件的意思是指该控件里面的内容仅仅能水平或垂直排列.也就 ...
- .Net程序猿乐Android开发---(4)注册页面布局
接下来我们介绍的登陆页面布局,在本节中,我们看一下注册页面布局,页面布局大同小异,来一起熟悉下基本控件的使用方法. 效果图: 1.加入注冊页面 右键选中layout目录,加入注冊页面.例如以下图 点击 ...
- .Net程序员玩转Android开发--ListView单击事件
public class ListViewClickActivity extends Activity { private ListView lv; SimpleAdap ...
- android 开发 简单的页面布局
package com.example.test; import android.app.Activity; import android.os.Bundle; import android.view ...
- .Net程序员玩转Android系列之一~Java快速入门
前言 前段时间受公司业务发展需要,探索性进入Android开发领域.一切从零开始,java基础,Java进阶,Android框架学习,Eclipse熟悉,最终到第一个即时通讯App完成,历经一个月的时 ...
- 作为一个程序员怎么通过android开发赚钱
上面是一个程序员通过Android开发每天的收入,信则有! 自己学安卓差不多,有一年了.我本来是从事javaweb开发的,可能学习安卓上手会快点.其实安卓没有那难 .首先开发安卓程序,要有一个,开 ...
随机推荐
- 抓取锁的sql语句-第五次修改
CREATE OR REPLACE PROCEDURE SOLVE_LOCK AS V_SQL VARCHAR2(3000); --定义 v_sql 接受抓取锁的sql语句V_SQL02 VARCHA ...
- 玩转iOS 9的UIDynamics(转)
转自 http://www.cocoachina.com/ios/20150716/12613.html 本文由CocoaChina翻译小组成员AGSpider(微博)翻译自fancypixel的博客 ...
- javascript判断浏览器是否是隐私模式
判断浏览器是否是隐私模式,隐私模式下有写api不可用 1. try { localStorage['test'] = 'test'; //localStorage和sessionStorage都存在, ...
- 低字节序和高字节序相互转换(Little Endian/Big Endian)
这个例子展示了如何转换整形数字的字节顺序,该方法可以用来在little-endian和big-endian之间转换. 说明:Windos(x86,x64)和Linux(x86,x64)都是little ...
- C++ Primer 5th 第12章 动态内存
练习12.1:在此代码的结尾,b1 和 b2 各包含多少个元素? StrBlob b1; { StrBlob b2 = {"a", "an", "th ...
- 纯js实现分页
原理:所有数据已加载好,js通过遍历部分显示,实现分页效果 html代码 <html> <head> <meta charset='utf-8'> <scri ...
- php开发中的url地址传输加密解密函数
function keyED($txt,$encrypt_key) //定义一个keyED { $encrypt_key = md5($encrypt_key); $ctr=0; $tmp = ''; ...
- Flask学习记录之使用Werkzeug散列密码
数据库中直接存放明文密码是很危险的,Werkzeug库中的security能够方便的实现散列密码的计算 security库中 generate_password_hash(password,metho ...
- iOS开发——常用宏的定义
有些时候,我们需要将代码简洁化,这样便于读代码.我们可以将一些不变的东东抽取出来,将变化的东西作为参数.定义为宏,这样在写的时候就简单多了. 下面例举了一些常用的宏定义和大家分享: 1. 判断设备的操 ...
- MVC中的控制器
authour: chenboyi updatetime: 2015-04-25 12:22:35 friendly link: 目录: 1,思维导图 2,控制器约定 3,action向视图传值的 ...