【Android UI】使用RelativeLayout与TableLayout实现登录界面
使用RelativeLayout与TableLayout分别实现两种登录界面,学习RelativeLayout布局
中如何对齐与调整组件相对位置,使用TableLayout实现登录界面,学习如何设置列
的长度,与对齐方式等。
RelativeLayout中使用如下属性调整组件相对位置
layout_alignParentLeft :表示组件左对齐布局
layout_alignParentRight:表示组件有对齐布局
layout_below="@+id/edit1":表示组件在edit1组件下面
layout_toRightOf="@+id/edit1":表示组件放在edit1的右边
效果图:
TableLayout实现效果:
RelatvieLayout实现登录的XML文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_height="wrap_content"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:text="用户名:"
android:layout_marginLeft="5dp"
android:textColor="@color/green"
android:layout_marginRight="5dp"
android:layout_alignParentLeft="true">
</TextView>
<EditText android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_toRightOf="@+id/textView1"
android:id="@+id/editText1">
</EditText>
<TextView android:layout_height="wrap_content"
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:text="密码:"
android:layout_marginLeft="5dp"
android:textColor="@color/green"
android:layout_marginRight="5dp"
android:layout_below="@+id/editText1"
android:layout_alignParentLeft="true">
</TextView>
<EditText android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_toRightOf="@+id/textView2"
android:id="@+id/editText2"
android:layout_below="@+id/editText1">
</EditText>
<Button android:layout_height="wrap_content"
android:text="登录"
android:layout_width="wrap_content"
android:layout_below="@+id/editText2"
android:layout_alignParentLeft="true"
android:id="@+id/button1">
</Button>
<Button android:layout_height="wrap_content"
android:text="注册"
android:layout_width="wrap_content"
android:layout_below="@+id/editText2"
android:layout_toRightOf="@+id/button1"
android:id="@+id/button2">
</Button>
</RelativeLayout>
TableLayout实现登录的XML文件
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow android:id="@+id/TableRow01">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="帐号"
android:textColor="@color/green"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
</TextView>
<EditText android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</TableRow>
<TableRow android:id="@+id/TableRow02">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="密码"
android:textColor="@color/green"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
</TextView>
<EditText android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</TableRow>
<TableRow android:id="@+id/TableRow03"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="right">
<Button android:id="@+id/login_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"
android:textColor="@color/green"
/>
<Button android:id="@+id/register_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="注册"
android:textColor="@color/green"
/>
</TableRow>
</TableLayout>
【Android UI】使用RelativeLayout与TableLayout实现登录界面的更多相关文章
- [转]Android:布局实例之模仿QQ登录界面
Android:布局实例之模仿QQ登录界面 预览图: 准备: 1.找到模仿对象 QQ登陆界面UI下载>>>>> 2.导入工程 3.查看布局结构和使用控件 其对应效果图分布 ...
- Android:布局实例之模仿QQ登录界面
预览图: 准备: 1.找到模仿对象 QQ登陆界面UI下载>>>>> 2.导入工程 3.查看布局结构和使用控件 其对应效果图分布为 4.分析样式选择器 下拉箭头2种样式:点 ...
- Android:布局实例之模仿京东登录界面
预览图及布局结构参考: 布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout ...
- Android UI系列-----RelativeLayout的相关属性
本篇随笔将主要记录一些RelatieLayout的相关属性,并将猜拳游戏通过RelativeLayout实现出来 RelativeLayout的几组属性 第一组属性:android:layout_be ...
- Android UI经常使用实例 怎样实现欢迎界面(Splash Screen)
在Android平台下.下载一个应用后,首次打开映入眼帘的便是Splash Screen,暂且不说Android的设计原则提不提倡这样的Splash Screen.先来看看一般使用Splash Scr ...
- 【Android UI设计与开发】2.引导界面(二)使用ViewPager实现欢迎引导页面
1.实现的效果 2.编码前的准备工作 ViewPager是Android3.0之后提供的新特性,所以要想让你的应用向下兼容就必须要android-support-v4.jar这个包的支持,这是一个来自 ...
- 【Android UI设计与开发】3.引导界面(三)实现应用程序只启动一次引导界面
大部分的引导界面基本上都是千篇一律的,只要熟练掌握了一个,基本上也就没什么好说的了,要想实现应用程序只启动一次引导界面这样的效果,只要使用SharedPreferences类,就会让程序变的非常简单, ...
- 【Android UI设计与开发】1.引导界面(一)ViewPager介绍和简单实现
1.ViewPager 实现效果图 2.ViewPager 实现功能 ViewPager类提供了多界面切换的新效果,新效果有如下特征: <1>当前显示一组界面中的其中一个界面: <2 ...
- Android四种基本布局(LinearLayout \ RelativeLayout \ FrameLayout \ TableLayout)
------------------------------------------LinearLayout---------------------------------------------- ...
随机推荐
- openldap quick start guide
openldap 2.4 在centos 7 x64系统上部署 1 下载源码编译解压tar -xvf xx ./configure make && make install 2 更改配 ...
- Java(静态)变量、(静态)代码块、构造方法的执行顺序
Java(静态)变量.(静态)代码块.构造方法的执行顺序 总结 1.父类静态变量和静态代码块(先声明的先执行); 2.子类静态变量和静态代码块(先声明的先执行); 3.父类的变量和代码块(先声明的先执 ...
- [C#] 实现可设置超时的 Task
前言 如何实现支持超时的 Task ? 关键点: Task.WhenAny 实现 一个扩展方法就可以搞定. // 有返回值 public static async Task<TResult> ...
- Codeforces Round #436 (Div. 2) E. Fire(dp 记录路径)
E. Fire time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- Python开发基础-Day29多线程
概念 进程:进程就是一个程序在一个数据集上的一次动态执行过程 程序:代码 数据集:程序执行过程中需要的资源 进程控制块:完成状态保存的单元 线程:线程是寄托在进程之上,为了提高系统的并发性 线程是进程 ...
- [NOI2011]阿狸的打字机 --- AC自动机 + 树状数组
[NOI2011] 阿狸的打字机 题目描述: 阿狸喜欢收藏各种稀奇古怪的东西,最近他淘到一台老式的打字机. 打字机上只有28个按键,分别印有26个小写英文字母和'B'.'P'两个字母.经阿狸研究发现, ...
- BFS洪水
试题描述: 已经连续下了几天雨,却还是没有停的样子.土豪CCY刚从外地赚完1e元回来,知道不久除了自己别墅,其他的地方都将会被洪水淹没. CCY所在的城市可以用一个N*M(N,M<=50)的地图 ...
- CROC 2016 - Elimination Round (Rated Unofficial Edition) B. Mischievous Mess Makers 贪心
B. Mischievous Mess Makers 题目连接: http://www.codeforces.com/contest/655/problem/B Description It is a ...
- JAVA容器-重点总结与深度解析
重点内容总结 问题思考 问题思考解析
- 更新yum源/apt-get源
国内开源镜像站有:网易: http://mirrors.163.com/ 搜狐: http://mirrors.sohu.com/阿里云: http://mirrors.aliyun.com/北京理工 ...