设为首页收藏本站

Scripts 学盟

 找回密码
 加入学盟

QQ登录

只需一步,快速开始

查看: 2620|回复: 2

android 开发 RelativeLayout 使用(一) [复制链接]

Rank: 8Rank: 8

那个谁 发表于 2011-5-24 11:14:37 |显示全部楼层
前面讲了RelativeLayout的属性。。今天来做个dome 代码如下:
  1. <RelativeLayout
  2.   xmlns:android="http://schemas.android.com/apk/res/android"
  3.   android:layout_width="match_parent"
  4.   android:layout_height="match_parent" android:padding="10dip">
  5.   <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/lable" android:text="请输入用户名">
  6.   </TextView>
  7.   <EditText android:id="@+id/entry"  android:layout_width="fill_parent" android:layout_height="wrap_content"
  8.    android:layout_below="@id/lable">
  9.   </EditText>
  10.   <Button android:id="@+id/cancel"  android:layout_width="wrap_content" android:layout_height="wrap_content"
  11.    android:layout_below="@id/entry" android:layout_alignParentRight="true" android:layout_marginLeft="10dip" android:text="取消"></Button>
  12. <Button android:id="@+id/ok"  android:layout_width="wrap_content" android:layout_height="wrap_content"
  13. android:layout_toLeftOf="@id/cancel" android:layout_alignTop="@id/cancel" android:text="确定"
  14. >
  15. </Button>
  16. </RelativeLayout>
复制代码
效果:
  1. <RelativeLayout
  2.   xmlns:android="http://schemas.android.com/apk/res/android"
  3.   android:layout_width="match_parent"
  4.   android:layout_height="match_parent" android:padding="10dip">
  5.   <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/lable" android:text="请输入用户名">
  6.   </TextView>
  7.   <EditText android:id="@+id/entry"  android:layout_width="fill_parent" android:layout_height="wrap_content"
  8.    android:layout_below="@id/lable">
  9.   </EditText>
  10.   <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/lable2" android:text="请输入密码"
  11.   android:layout_below="@id/entry" >
  12.   </TextView>
  13.   <EditText android:id="@+id/entrypassword"  android:layout_width="fill_parent" android:password="true" android:layout_height="wrap_content"
  14.    android:layout_below="@id/lable2">
  15.   </EditText>
  16.   
  17.   <Button android:id="@+id/cancel"  android:layout_width="wrap_content" android:layout_height="wrap_content"
  18.    android:layout_below="@id/entrypassword" android:layout_alignParentRight="true" android:layout_marginLeft="10dip" android:text="取消"></Button>
  19. <Button android:id="@+id/ok"  android:layout_width="wrap_content" android:layout_height="wrap_content"
  20. android:layout_toLeftOf="@id/cancel" android:layout_alignTop="@id/cancel" android:text="确定"
  21. >
  22. </Button>
  23. </RelativeLayout>
复制代码
qqq.png
qqq.png
2

查看全部评分

Rank: 6Rank: 6

Yisin 发表于 2011-5-24 19:11:23 来自手机 |显示全部楼层
来学习一下
路不好走,你却依旧满眼的爱,找不到理由...

使用道具 举报

管理员

超级大菜鸟

Rank: 9Rank: 9Rank: 9

混混@普宁.中国 实名认证  发表于 2011-7-12 00:17:40 |显示全部楼层
我哪里吝啬了

使用道具 举报

您需要登录后才可以回帖 登录 | 加入学盟

手机版|Scripts 学盟   |

GMT+8, 2024-4-19 08:43 , Processed in 1.109707 second(s), 18 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部