使用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实现登录界面的更多相关文章

  1. [转]Android:布局实例之模仿QQ登录界面

    Android:布局实例之模仿QQ登录界面 预览图: 准备: 1.找到模仿对象 QQ登陆界面UI下载>>>>> 2.导入工程 3.查看布局结构和使用控件 其对应效果图分布 ...

  2. Android:布局实例之模仿QQ登录界面

    预览图: 准备: 1.找到模仿对象 QQ登陆界面UI下载>>>>> 2.导入工程 3.查看布局结构和使用控件 其对应效果图分布为 4.分析样式选择器 下拉箭头2种样式:点 ...

  3. Android:布局实例之模仿京东登录界面

    预览图及布局结构参考: 布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout ...

  4. Android UI系列-----RelativeLayout的相关属性

    本篇随笔将主要记录一些RelatieLayout的相关属性,并将猜拳游戏通过RelativeLayout实现出来 RelativeLayout的几组属性 第一组属性:android:layout_be ...

  5. Android UI经常使用实例 怎样实现欢迎界面(Splash Screen)

    在Android平台下.下载一个应用后,首次打开映入眼帘的便是Splash Screen,暂且不说Android的设计原则提不提倡这样的Splash Screen.先来看看一般使用Splash Scr ...

  6. 【Android UI设计与开发】2.引导界面(二)使用ViewPager实现欢迎引导页面

    1.实现的效果 2.编码前的准备工作 ViewPager是Android3.0之后提供的新特性,所以要想让你的应用向下兼容就必须要android-support-v4.jar这个包的支持,这是一个来自 ...

  7. 【Android UI设计与开发】3.引导界面(三)实现应用程序只启动一次引导界面

    大部分的引导界面基本上都是千篇一律的,只要熟练掌握了一个,基本上也就没什么好说的了,要想实现应用程序只启动一次引导界面这样的效果,只要使用SharedPreferences类,就会让程序变的非常简单, ...

  8. 【Android UI设计与开发】1.引导界面(一)ViewPager介绍和简单实现

    1.ViewPager 实现效果图 2.ViewPager 实现功能 ViewPager类提供了多界面切换的新效果,新效果有如下特征: <1>当前显示一组界面中的其中一个界面: <2 ...

  9. Android四种基本布局(LinearLayout \ RelativeLayout \ FrameLayout \ TableLayout)

    ------------------------------------------LinearLayout---------------------------------------------- ...

随机推荐

  1. 基于Redis实现——分布式锁与实现

    实现 使用的是jedis来连接Redis. 实现思想 获取锁的时候,使用setnx加锁,并使用expire命令为锁添加一个超时时间,超过该时间则自动释放锁,锁的value值为一个随机生成的UUID,通 ...

  2. php抓取一个页面的图片

    思路: 1.找到一个页面 2.正则过滤所有的img 3.正则过滤出所有的src的属性 4.获取链接信息,写入文件 file_get_contents(), file_put_contents() 5. ...

  3. 微信用户授权,获取code

    1.进入微信公众平台 2.进入到   开发->接口授权,点击 网页服务->网页授权->网页授权获取用户基本信息   后面的“修改“. 3.点击网页授权域名的设置 4.设置授权回调域名 ...

  4. UVA12995 Farey Sequence [欧拉函数,欧拉筛]

    洛谷传送门 Farey Sequence (格式太难调,题面就不放了) 分析: 实际上求分数个数就是个幌子,观察可以得到,所求的就是$\sum^n_{i=2}\phi (i)$,所以直接欧拉筛+前缀和 ...

  5. python log的处理方式

    python log的处理方式 配置文件 #! /usr/bin/env python # -*- coding: utf-8 -*- # __author__ = "Q1mi" ...

  6. 前端使用express mock数据

    项目中使用的是RESTFUL接口规范,项目框架用的是vue,项目开始时,调研了几个比较有名的mock数据的插件:比如webpack的中间件api-mock,json-server,mockjs,还有e ...

  7. Xcode 7.0正式版发布了

    Xcode 7.0正式版发布了     下载地址:链接: http://pan.baidu.com/s/1FNkPS 密码: ee42     本文由大学霸整理,转载请注明出处,尊重IT人!

  8. 【BZOJ 4171】 4171: Rhl的游戏 (高斯消元)

    4171: Rhl的游戏 Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 74  Solved: 33[Submit][Status][Discuss] ...

  9. 批量 修改 android eclipse 项目名

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 最外层的 文件夹名字.

  10. bzoj 2055: 80人环游世界 -- 上下界网络流

    2055: 80人环游世界 Time Limit: 10 Sec  Memory Limit: 64 MB Description     想必大家都看过成龙大哥的<80天环游世界>,里面 ...