.Net程序猿玩转Android开发---(3)登陆页面布局

时间:2022-09-01 17:06:09

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

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

.Net程序猿玩转Android开发---(3)登陆页面布局

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. &period;Net程序猿玩转Android开发---&lpar;11&rpar;页面跳转

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

  2. &period;Net程序猿玩转Android开发---&lpar;7&rpar;相对布局RelativeLayout

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

  3. &period;Net程序猿玩转Android开发---&lpar;8&rpar;表格布局TableLayout

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

  4. &period;Net程序猿玩转Android开发---&lpar;6&rpar;线性布局LinearLayout

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

  5. &period;Net程序猿乐Android开发---&lpar;4&rpar;注册页面布局

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

  6. &period;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. &period;Net程序员玩转Android系列之一~Java快速入门

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

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

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

随机推荐

  1. Android音频介绍

    这个世界音频设备千变万化,Android也不可能为每种设备都提供支持.Android定义了一个框架,这个框架来适配底层的音频设备.该适配层的定义位于: hardware/libhardware_leg ...

  2. Qt Examples Qt实例汇总

    ActiveQt Examples Using ActiveX from Qt applications. Animation Framework Examples Doing animations ...

  3. Reading package lists&period;&period;&period; Error&excl; 解决方案

    ubuntu 下安装python开发包,执行命令 sudo apt-get install python-dev,报错: Reading package lists... Error! E: Enco ...

  4. 打败Google的灵童今在何方?

    微软和雅虎宣布在搜索和广告上10年合作,这事儿不知是不是前不久虚惊一场的微软收购雅虎案的好戏重演之序幕. 从表面上看,这次的合作改变不了搜索和广告目前的世界格局,也构不成对Google的致命威胁,反倒 ...

  5. IE浏览器兼容性的痛苦

    做了一个弹出框的demo,在狐火,chrome,IE11中运行得好好的. 但是在IE8中死活不显示对话框,感觉IE8根本没有执行下面的javascript代码. 甚至,我简单的写alert(123), ...

  6. SUBTOTAL 函数与所在行

    SUBTOTAL 函数与所在行 设计要点:数据汇总.隐藏.筛选 阿金:给你推荐一个函数SUBTOTAL. 秀秀:又是函数!俺不喜欢. 阿金:虽然你不喜欢函数,但是你也离不了啊,比如汇总. 秀秀:那倒是 ...

  7. Springboot中关于跨域问题的一种解决方法

    前后端分离开发中,跨域问题是很常见的一种问题.本文主要是解决 springboot 项目跨域访问的一种方法,其他 javaweb 项目也可参考. 1.首先要了解什么是跨域 由于前后端分离开发中前端页面 ...

  8. Codeforces Round &num;545 &lpar;Div&period; 2&rpar; D

    链接:http://codeforces.com/contest/1138/problem/D 啊啊啊啊啊啊,自闭啊,比赛的时候判断条件 if(s1[i-1]=='0') aa++;写成了 if(s1 ...

  9. 第十四个目标 &lpar;fzu&rpar;

    http://acm.fzu.edu.cn/contest/problem.php?cid=151&sortid=8 Problem Description 目暮警官.妃英里.阿笠博士等人接连 ...

  10. ActiveMQ 权限(一)

    在 ActiveMQ 认证(一) 中,若用户名或密码不正确,不能连接到ActiveMQ.我们可以通过配置文件,确用户是否有消息的读取.写入和管理的权限. 在plugin配置节点下,配置以下信息: &l ...