Android UI组件----用相对布局RelativeLayout做一个登陆界面
【声明】
欢迎转载,但请保留文章原始出处→_→
生命壹号:http://www.cnblogs.com/smyhvae/
文章来源:http://www.cnblogs.com/smyhvae/p/3839986.html
【正文】
两个小时的学习成果,对于我这种还没入门但渴望不断进步的初学者来说,是一种激励。通过自己一行一行的敲代码,实现了用相对布局做一个登陆界面的效果。
XML文件完整版代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp" > <!--定义"登陆界面"四个字的文本框,放在最上方的中央 -->
<TextView
android:id="@+id/lableView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="登陆界面" /> <!--定义输入用户名的文本编辑框 -->
<EditText
android:id="@+id/usernameView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/lableView"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:hint="username" /> <!--定义输入密码的文本编辑框 -->
<EditText
android:id="@+id/passwordView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/usernameView"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:hint="password"
android:inputType="textPassword" /> <!--定义“取消”的按钮 -->
<Button
android:id="@+id/cancleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/passwordView"
android:layout_alignParentRight="true"
android:text="取消" /> <!--定义“确定”的按钮,放在“取消”按钮的左边 -->
<Button
android:id="@+id/okButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/cancleButton"
android:layout_toLeftOf="@id/cancleButton"
android:text="确定" /> </RelativeLayout>
代码解释如下:
最终在手机上运行后,显示效果如下:
我的公众号
想学习代码之外的软技能?不妨关注我的微信公众号:生命团队(id:vitateam)。
扫一扫,你将发现另一个全新的世界,而这将是一场美丽的意外:
Android UI组件----用相对布局RelativeLayout做一个登陆界面的更多相关文章
- Android UI组件----ListView列表控件详解
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...
- Android UI基础之五大布局
Android UI基础之五大布局 Android的界面是有布局和组件协同完成的,布局好比是建筑里的框架,而组件则相当于建筑里的砖瓦.组件按照布局的要求依次排列,就组成了用户所看见的界面.Andro ...
- Android 高级UI设计笔记08:Android开发者常用的7款Android UI组件(转载)
Android开发是目前最热门的移动开发技术之一,随着开发者的不断努力和Android社区的进步,Android开发技术已经日趋成熟,当然,在Android开源社区中也涌现了很多不错的开源UI项目,它 ...
- Android UI组件:布局管理器
为了更好的管理Android应用的用户界面中的组件,Android提供了布局管理器.通过使用布局管理器,Android应用的图形用户界面具有良好的平台无关性.通常,推荐使用布局管理器来管理组件的分布. ...
- Android——四大组件、六大布局、五大存储
一.android四大组件 (一)android四大组件详解 Android四大组件分别为activity.service.content provider.broadcast receiver. 1 ...
- 这是一个比较全的Android UI 组件
Android组件及UI框架大全 原文地址:http://blog.csdn.net/smallnest/article/details/38658593 Android 是目前最流行的移动操作系统 ...
- Android学习笔记(14):相对布局RelativeLayout
相对布局RelativeLayout,继承自ViewGroup.相对布局的子组件的位置总是相对于兄弟组件或者父容器决定的. RelativeLayout支持的XML属性: android:gravit ...
- Android UI组件----AppWidget控件入门详解
Widget引入 我们可以把Widget理解成放置在桌面上的小组件(挂件),有了Widget,我们可以很方便地直接在桌面上进行各种操作,例如播放音乐. 当我们长按桌面时,可以看到Widget选项,如下 ...
- Android UI学习 - FrameLayou和布局优化(viewstub)
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://android.blog.51cto.com/268543/308090 Fram ...
随机推荐
- jython实现java运行python代码
Jython是一种完整的语言,而不是一个Java翻译器或仅仅是一个Python编译器,它是一个Python语言在Java中的完全实现.最近的一个项目需要将python代码转换成java实现,所以用了一 ...
- Amazon S3 功能介绍
一 .Amazon S3介绍 Amazon Simple Storage Service (Amazon S3) 是一种对象存储,它具有简单的 Web 服务接口,可用于在 Web 上的任何位置存储和检 ...
- 图解-安卓中调用OpenGL
游戏开发中经常使用到OpenGL,当然很多人都喜欢直接用现有的游戏引擎,但相信了解的更多对你没有坏处 安卓开发中,采用的OpenGL ex2的规范,前几天看了下这个规范,整体上难度比1.0规范难度加大 ...
- Chapter 3 Phenomenon——9
"You were over there," I suddenly remembered, and his chuckle stopped short. “你之前不在这里”我突然记 ...
- 忽略“Signal: SIGSEGV (Segmentation fault)”
1. touch ~/.gdbinit 2. 在.gdbinit文件中添加“handle SIGSEGV nostop noprint pass”
- 深度剖析Dubbo源码
-----------------学习dubbo源码,能给你带来什么好处?----------- 1.提升SOA的微服务架构设计能力 通过读dubbo源码是一条非常不错的通往SOA架构设计之路,毕 ...
- lucene源码分析(4)Similarity相似度算法
lucene 7.5.0默认的评分Similarity是BM25Similarity (IndexSearcher.java) // the default Similarity private st ...
- 遇见CUBA CLI
原文:Meet CLI for CUBA Platform 翻译:CUBA China CUBA-Platform 官网 : https://www.cuba-platform.com CUBA Ch ...
- rsyslog 配置 二
转自:https://www.cnblogs.com/cherishry/p/6775163.html rsyslog 配置 二 # rsyslog configuration file # For ...
- finally 的作用是什么?
在java中finally首先必须使用在所有catch的最后位置, 无论是否抛出异常,finally代码块总是会被执行.就算是没有catch语句同时又抛出异常的情况下,finally代码块任然会被执行 ...