使用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. Java虚拟机四:垃圾回收算法与垃圾收集器

    在Java运行时的几个数据区域中,程序计数器,虚拟机栈,本地方法栈3个区域随着线程而生,随线程而灭,因此这几个区域的内存分配和回收具有确定性,不需要过多考虑垃圾回收问题,因为方法结束或者线程结束时,内 ...

  2. Typo: In word 拼写检查

    Settings->Inspections > Spelling > Typo 评写检查,

  3. 利用gmpy2破解rsa

    gmpy2的相关文档: https://gmpy2.readthedocs.io/en/latest/ ================ 题目: 来自实验吧的rsarsa:http://www.shi ...

  4. logging记录日志

    日志是一个系统的重要组成部分,用以记录用户操作.系统运行状态和错误信息.日志记录的好坏直接关系到系统出现问题时定位的速度.logging模块Python2.3版本开始成为Python标准库的一部分. ...

  5. 创建基于主-从视图的应用程序(Master-Detail Application)

    以Master-Detail Application创建的应用程序在iPad和iPhone上都能运行,虽然模板解决了大部分问题,但还是有一些Apple遗留问题需要解决.使用该模板创建项目时,需要将下拉 ...

  6. mysql 之 用python操作数据库

  7. BZOJ2754 SCOI2012喵星球上的点名

    绝世好题. 正当我犹豫不决时,hzwer说:“MAP!!!” 没错这题大大的暴力,生猛的stl,贼基尔爽,,ԾㅂԾ,, 由于我们求点名在名字中的子串个数,所以将点名建AC自动机,记录节点属于哪次点名, ...

  8. [BZOJ4517][SDOI2016]排列计数(错位排列)

    4517: [Sdoi2016]排列计数 Time Limit: 60 Sec  Memory Limit: 128 MBSubmit: 1616  Solved: 985[Submit][Statu ...

  9. 【最小表示法】BZOJ2176-Strange string(unsigned char!!!)

    [题目大意] 给定一个字符串S = {S1, S2, S3 … Sn}, 如果在串SS中, 子串T(|T| = n)为所有长度为n的SS的字串中最小的(字符串的比较), 则称T为”奇怪的字串”. 你的 ...

  10. 【8.26校内测试】【重构树求直径】【BFS模拟】【线段树维护DP】

    题目性质比较显然,相同颜色联通块可以合并成一个点,重新建树后,发现相邻两个点的颜色一定是不一样的. 然后发现,对于一条链来说,每次把一个点反色,实际上使点数少了2个.如下图 而如果一条链上面有分支,也 ...