这一节我们来看看登陆页面如何布局。对于刚接触到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. SQL 中的好习惯和坏习惯

    在程序员日常的工作中,SQL可以说不可避免的,高效的SQL可以带来更加愉悦的体验.好的SQL书写习惯会给我们的工作带来极大的好处.简单总结下SQL的好习惯和坏习惯. IN和NOT IN 操作符 编码中 ...

  2. 【转】 HVTableView创建--展开/折叠列表能 AAShareBubbles社会分享动画组

    原文: http://blog.csdn.net/billfanggs/article/details/17279969 HVTableView HVTableView是UITableView(带有展 ...

  3. display: -webkit-flex; 手机上图下文字,pad上有浮动。

    <article> <div class="boxt"> <div class="boxt-right"><img s ...

  4. git在windows常用命令

    git add * git commit(会自动打开一个文本文档让你写提交注释),若是不好用可以用 git commit -m "注释" git push

  5. PHP Countable接口

    实现该接口可以使用count()方法来获取集合的总数

  6. 动态内存分配(new)和释放(delete)

    在之前我们所写过的程序中,所必需的内存空间的大小都是在程序执行之前就已经确定了.但如果我们需要内存大小为一个变量,其数值只有在程序运行时 (runtime)才能确定,例如有些情况下我们需要根据用户输入 ...

  7. jQuery实现checkbox全选反选及删除等操作

    1.list.html 说明:用checkbox数组Check[]存放每一行的ID值 <div id="con"> <table width="100% ...

  8. angularJS中XHR与promise

    angularJS应用是完全运行在客户端的应用,我们可以通过angularJS构建一个不需依赖于后端,同时能够实现动态内容和响应的web应用,angularJS提供了将应用与远程服务器的信息集成在一起 ...

  9. 使用grunt压缩css是能否设置background-size不压缩进去呢?否则ie8不能识别

    .index-bg{ background:url(img/index-bg-t.5344b19d.jpg) center center/cover no-repeat } 比如上面这样ie8不能识别 ...

  10. Python自动化运维之17、Python操作 Memcache、Redis、RabbitMQ

    一.Memcached Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的 ...