效果图:
xml布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loginPageLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/loginUI_Label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/LoginUI"
android:textSize="14pt"
/>
<EditText
android:id="@+id/loginUsername"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/loginUI_Label"
android:paddingLeft="60dip"/>
<TextView android:id="@+id/loginUsername_Label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/loginUsername"
android:layout_alignTop="@id/loginUsername"
android:layout_marginTop="10dip"
android:layout_marginLeft="5dip"
android:text="@string/LoginUsernameLabel"
/>
<EditText
android:id="@+id/loginPassword"
android:layout_below="@id/loginUsername"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:password="true"
android:paddingLeft="55dip"
/>
<TextView android:id="@+id/loginPassword_Label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/loginPassword"
android:layout_alignTop="@id/loginPassword"
android:layout_marginTop="10dip"
android:layout_marginLeft="5dip"
android:text="@string/LoginPasswordLabel"
/>
<CheckBox
android:id="@+id/loginCheckbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/loginPassword"
android:layout_alignLeft="@id/loginPassword"
android:hint="@string/checkboxRemberPwdLabel"
android:checked="true"
/>
<Button
android:id="@+id/loginBtn"
android:layout_below="@id/loginPassword"
android:layout_toRightOf="@id/loginCheckbox"
android:layout_marginLeft="30dip"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:text="@string/btnLoginLabel"
/>
</RelativeLayout>
这个其实就是提示标签控件(TextView)与文本框控件(EditText)的左上角对齐:通过android:layout_alignLeft及android:layout_alignTop属性来设置。
然后设置文本框控件的内边距:android:paddingLeft="60dip"
android:paddingLeft:控件内部左边距(控件里的文字等内容与控件左侧的距离)
android:layout_marginLeft:控件外部左边距(控件左侧与父控件左侧的距离)
---------------------------------------------------------------------------------------------
分享到:
相关推荐
【Android开发学习25】界面布局之相对布局RelativeLayout(代码)
Android 相对布局 RelativeLayout 属性
Android相对布局RelativeLayout的基本用法,相对布局是最实用的布局。
Android移动应用开发相对布局RelativeLayout的特点.pdf 学习资料 复习资料 教学资源
总结android中相对布局RelativeLayout的所有属性及使用方法。适合初级程序员
智能家居系统 相对布局RelativeLayout.doc 学习资料 复习资料 教学资源
相对布局我最新喜欢的布局,也是game开发,照相机以及增钱现实中最常用的布局!
这个程序写了对相对布局和绝对布局的例子,帮助大家理解两者的使用和区别。
Android移动应用开发相对布局RelativeLayout的常用属性列表.pdf 学习资料 复习资料 教学资源
相对布局(RelativeLayout):相对其它组件的布局方式。 绝对布局(AbsoluteLayout):按照绝对坐标来布局组件。 1. 线性布局 线性布局是Android开发中最常见的一种布局方式,它是按照垂直或者水平方向来布局...
主要介绍了Android编程之绝对布局AbsoluteLayout和相对布局RelativeLayout实现方法,结合实例形式详细分析了Android绝对布局AbsoluteLayout和相对布局RelativeLayout的原理与使用技巧,需要的朋友可以参考下
功能演示android 布局属性置于目标 id 组件的上方置于与目标 id 组件同样的基线上让自己的下边界与目标 id 组件的下边界在同一个位置让自己的左边界与
RelativeLayout是相对布局控件:以控件之间相对位置或相对父容器位置进行排列,下面通过本文给大家介绍Android布局之RelativeLayout相对布局,涉及到android relativelayout相对布局相关知识,对android ...
主要介绍了Android App的相对布局RelativeLayout,文中举了一个登录界面的XML布局例子,非常直观,需要的朋友可以参考下
RelativeLayout是相对布局控件,以控件之间相对位置或相对父容器位置进行排列。下面这篇文章主要给大家介绍了关于Android中相对布局RelativeLayout的一些技巧,需要的朋友可以参考借鉴,下面来一起看看吧。
移动互联网应用
智能家居系统应用
NULL 博文链接:https://sarin.iteye.com/blog/1756332
android布局属性RelativeLayout详解.