简单的RelativeLayout布局

简单的RelativeLayout布局实例

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5      >
 6
 7     <TextView
 8         android:id="@+id/textView1"
 9         android:layout_width="wrap_content"
10         android:layout_height="wrap_content"
11         android:layout_alignParentTop="true"
12         android:layout_centerHorizontal="true"
13         android:layout_marginTop="20dp"
14         android:text="Please input the username and password to log on."
15         android:textSize="14sp"
16         android:textAppearance="?android:attr/textAppearanceMedium"
17         android:layout_marginLeft="20dp"
18         android:layout_marginRight="20dp"
19         android:layout_marginBottom="20dp"
20          />
21     <TextView
22         android:id="@+id/text_username"
23         android:layout_width="wrap_content"
24         android:layout_height="wrap_content"
25         android:layout_below="@id/textView1"
26         android:layout_alignLeft="@id/textView1"
27         android:layout_marginRight="20dp"
28         android:text="User Name:"
29         android:textSize="20sp"
30         android:layout_marginBottom="20dp"
31         />
32
33     <EditText
34         android:id="@+id/edit_username"
35         android:layout_width="match_parent"
36         android:layout_height="wrap_content"
37         android:layout_alignBaseline="@id/text_username"
38         android:layout_toRightOf="@id/text_username"
39         android:layout_alignRight="@id/textView1"
40         android:layout_below="@id/textView1"
41         />
42
43
44     <TextView
45         android:id="@+id/text_psw"
46         android:layout_width="wrap_content"
47         android:layout_height="wrap_content"
48         android:layout_below="@id/text_username"
49         android:layout_alignLeft="@id/text_username"
50         android:layout_marginRight="20dp"
51         android:text="Password"
52         android:textSize="20sp"
53         />
54
55     <EditText
56         android:id="@+id/edit_psw"
57         android:layout_width="wrap_content"
58         android:layout_height="wrap_content"
59         android:layout_alignBaseline="@id/text_psw"
60         android:layout_alignLeft="@id/edit_username"
61         android:layout_alignRight="@id/edit_username"
62         android:layout_below="@id/edit_username"
63         android:inputType="textPassword" />
64
65     <Button
66         android:id="@+id/btn_logon"
67         android:layout_width="wrap_content"
68         android:layout_height="wrap_content"
69         android:layout_alignRight="@id/edit_psw"
70         android:text="Log in"
71         android:textSize="21sp"
72         android:layout_below="@id/edit_psw"
73         android:layout_marginTop="20dp"
74         android:layout_marginLeft="20dp"
75         />
76
77     <Button
78         android:id="@+id/btn_signin"
79         android:layout_width="wrap_content"
80         android:layout_height="wrap_content"
81         android:layout_alignBaseline="@+id/btn_logon"
82         android:layout_toLeftOf="@+id/btn_logon"
83         android:text="Sign in"
84         android:textSize="21sp" />
85
86 </RelativeLayout>
时间: 2024-08-06 07:56:59

简单的RelativeLayout布局的相关文章

RelativeLayout布局,不希望文本盖住其他组件

简单的图先看上一看 上面使用的是RelativeLayout布局(不要问为什么不用LinearLayout,因为最右边的信箱的右上角还会有个红点,相对布局直接些) 需要实现的效果是,TextView居中,当文本过长时不能覆盖住右边的组件,而是用点点代替超出部分. 最开始的想法是: 既然要居中,设置TextView的centerHorizontal为true: 不能超出右边,设置toLeftOf为右边的组件. 以上,so easy.但是运行起来的效果是,TextView并未居中!!! 为什么呢?尝

08 RelativeLayout 布局

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:ba

RelativeLayout布局

RelativeLayout用到的一些重要的属性: 第一类:属性值为true或falseandroid:layout_centerHrizontal 水平居中android:layout_centerVertical 垂直居中android:layout_centerInparent 相对于父元素完全居中android:layout_alignParentBottom 贴紧父元素的下边缘android:layout_alignParentLeft 贴紧父元素的左边缘android:layout_

Android - RelativeLayout布局

RelativeLayout布局 本文地址:http://blog.csdn.net/caroline_wendy RelativeLayout是一种相对布局方式,是根据属性进行对齐: A Layout where the positions of the children can be described in relation to each other or to the parent. 在布局中,子控件的位置根据相互之间的关系进行描述. Note that you cannot have

个人经验 - Android的RelativeLayout布局的layout_height属性设置为wrap_content时的坑

Android的RelativeLayout布局的layout_height属性设置为wrap_content时的坑: 此坑出现的条件: 1.RelativeLayout布局的layout_height属性设置为wrap_content 2.某“居中View”设置为layout_centerX(layout_centerVertical.layout_centerHorizontal.layout_centerInParent) 3.其它View相对于“居中View”做布局 此时坑出现了: 无论

UWP开发入门(九)——简单界面的布局技巧及屏幕适应

嘿嘿嘿,题目比较绕哈.本篇主要讨论一般情况下,页面的布局技巧,怎么将元素的展现尽量做到分辨率无关.基本的思路仍然是尽量少的标定具体的数字,而是用比列来标注各元素占据的空间. 这里我打算用易信的名片页来举例: Phone的界面看起来不错,大致以纵向排列.最上方是标题栏,头像部分居中,下面的文字以列表形式靠左对齐,最下部为留白.考虑到标题栏需要锚定在顶部,不参与比例分配.头像,文字和留白的占比大致为2.5:4:3.XAML中的Grid定义如下: <Grid.RowDefinitions> <

android基础知识复习——RelativeLayout布局属性、背景、半透明设置(XML设置)

转自:http://blog.csdn.net/fansongy/article/details/6817968 复习布局与XML,写了一个空的登录界面.XML的注释我写在当行的后面了.程序运行图: 主函数没有改动,不贴了.背景图片名为:background.jpg .看看main.xml吧. [html] view plaincopyprint? <?xml version="1.0" encoding="utf-8"?> <LinearLayo

RelativeLayout 布局参数

今天调布局的时候 想把界面做成横屏竖屏都可以的 突然发现之前理解的android:布局参数都是有问题的 今天贴出来 下次自己也记得 以下大部为用在RelativeLayout中的一些参数: android:layout_above 将该控件的底部至于给定ID的控件之上,但不会左对齐,默认置于父窗口最左边,会覆盖最左边的控件 android:layout_below 将该控件的顶部至于给定ID的控件之下,但不会左对齐,默认置于父窗口最左边,会覆盖最左边的控件 android:layout_toLe

20170830 wxPython的简单使用之布局

20170830 wxPython的简单使用 .wiz-code-container { position: relative; padding: 8px 0; margin: 5px 25px 5px 5px; text-indent: 0 } .CodeMirror { font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; color: black; font-size: 0.83rem } .Co