android注册界面高级,Android用户注册界面简单设计

本文详细介绍了如何设计一个Android用户注册界面,包括文本框、编辑框、按钮、单选按钮、复选框等控件的使用,以及布局设置和事件监听。用户需填写用户名、密码、确认密码,选择性别和身份,并同意服务条款才能完成注册。
摘要由CSDN通过智能技术生成

本文实例为大家分享了Android用户注册界面的设计,供大家参考,具体内容如下

I. 实例目标

设计一个用户注册界面,在其中要使用到一些基础控件,如 文本框、编辑框、按钮、复选框等控件

II. 技术分析

首先在布局文件中使用控件的标记来配置所需要的各个控件,然后在 主Activity中获取到该控件,给其添加监听器来监听其操作,最后在控制台输出所操作的内容。

III. 实现步骤

在Eclipse中创建 Android项目,名称为 TestUserRegister 。设计一个用户注册界面,在其中要使用到 文本框、编辑框、按钮、单选按钮、复选框、列表选择框、列表视图、图片视图 等控件。

(1)在项目 res 目录下的 drawable_ldpi 文件夹中,放入两张名称分别为 logo5.jpg 和 background3.jpg 的图片,用于作为显示的 logo 图片和背景图片。

(2)在项目的res/values 目录中新建数组资源文件 arrays.xml ,在该文件中添加两个字符串数组,名称分别为 type 和 care,代码如下

学生

老师

白领

工程师

其他

1.保护用户个人信息

2.用户在本网站上不得发布违法信息

3.保护个人账号和密码安全

4.本网站所有权和解释权归本网站拥有

(3)在项目的res/layout 目录下修改 activity _main.xml 文件,首先将界面整体布局改为表格布局,并设置背景,之后添加一个图像视图作为 logo 图像显示,代码如下:

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:background="@drawable/background3">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/logo5"

android:id="@+id/imageView02"

android:layout_margin="5dp"

android:adjustViewBounds="true"

android:maxWidth="75dp"

android:maxHeight="60dp"/>

上述代码中,android:adjustViewBounds 属性用于设置 ImageView 是否调整自己的边界来保持所需显示图片的长度变化,为 true 时表示调整自己的边界来保持所需显示图片的长度变化; android:maxWidth 和 android:maxHeight 分别表示 ImageView 的最大宽度和最大高度。

(4)添加三个 TableRow 表格行,并在其中添加 3 个 文本框(TextView) 和 编辑框控件(EditText) ,用来显示和填写 用户名、密码 和 确认密码。具体代码如下:

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="用户名:"

android:layout_marginLeft="5dp"/>

android:layout_width="250dp"

android:layout_height="wrap_content"

android:hint="请输入用户名"

android:id="@+id/editText01"

android:singleLine="true"

android:inputType="textPersonName"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="密码:"

android:layout_marginLeft="5dp"/>

android:layout_width="250dp"

android:layout_height="wrap_content"

android:hint="请输入密码"

android:id="@+id/editText02"

android:singleLine="true"

android:inputType="textPassword"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="确认密码:"

android:layout_marginLeft="5dp"/>

android:layout_width="250dp"

android:layout_height="wrap_content"

android:hint="请输入密码"

android:id="&

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值