android 布局随笔

先看一下登录界面。

本文章就是给初学者一个例子。

本例子使用RelativeLayout布局标签

 

现在上代码

 1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     xmlns:tools="http://schemas.android.com/tools"
 3     android:layout_width="fill_parent"
 4     android:layout_height="fill_parent"
 5     android:orientation="vertical"
 6     android:padding="10px">
 7         
 8         <TextView android:layout_width="wrap_content"
 9                       android:layout_height="wrap_content"
10                       android:id="@+id/tx_username"
11                       android:text="@string/tx_username"/>
12         
13         <EditText android:layout_width="fill_parent"
14                   android:layout_height="wrap_content"
15                   android:background="@android:drawable/editbox_background"
16                   android:layout_below="@id/tx_username"
17                   android:id="@+id/UserName"/>
18         
19         <TextView android:layout_width="wrap_content"
20                       android:layout_height="wrap_content"
21                       android:layout_below="@id/UserName"
22                       android:id="@+id/tx_password"
23                       android:text="@string/tx_password"/>
24         
25         <EditText android:layout_width="fill_parent"
26                       android:layout_height="wrap_content"
27                       android:inputType="textWebPassword"
28                       android:background="@android:drawable/editbox_background"
29                       android:layout_below="@id/tx_password"
30                       android:id="@+id/PassWord"/>
31         
32         <CheckBox
33                 android:id="@+id/Remember_PassWord"
34                 android:layout_width="wrap_content"
35                 android:layout_height="wrap_content"
36                 android:layout_alignParentLeft="true"
37                 android:layout_below="@id/PassWord"
38                 android:text="@string/tx_remember_password" />
39         
40         <Button
41                 android:id="@+id/Login"
42                 android:layout_width="wrap_content"
43                 android:layout_height="wrap_content"
44                 android:layout_gravity="center_horizontal"
45                 android:layout_below="@id/PassWord"
46                 android:layout_alignParentRight="true"
47                 android:text="@string/tx_login" />
48         
49 </RelativeLayout>

大概说一下,首先RelativeLayout是相对布局,其中的每个空间都用到了相对布局的标签

1、android:layout_below="@id/tx_username"  意思是:这个控件的顶部,在id为tx_username的下面;

2、android:layout_alignParentLeft="true"  意思是:这个控件,紧贴父控件的右侧;

3、android:padding="10px" 意思是:内边距为10px;

 

 


<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值