布局管理器(二)
1.相对布局
?
? ? 相对布局由RelativeLayout代表,相对布局容器内子组件的位置总是相对兄弟组件、父容器来决定的,因此这种布局方式被称为相对布局。
? ? 如果A组件的位置是由B组件的位置来决定的,Android要求先定义B组件,再顶定义A组件。
?
RelativeLayout的XML属性及相关方法说明
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:layout_height="fill_parent"><!--定义该组件位于父容器中间 --><TextView android:layout_height="wrap_content" android:layout_width="wrap_content"android:id="@+id/rview01"android:layout_centerInParent="true" android:background="@drawable/leaf"></TextView><!-- 定义该组件位于rview01组件的上方 --><TextView android:layout_height="wrap_content" android:layout_width="wrap_content"android:id="@+id/rview02"android:background="@drawable/leaf" android:layout_above="@+id/rview01" android:layout_alignLeft="@+id/rview01"></TextView><!-- 定义该组件位于rview01组件的下方 --><TextView android:layout_height="wrap_content" android:layout_width="wrap_content"android:id="@+id/rview03"android:background="@drawable/leaf" android:layout_below="@+id/rview01" android:layout_alignLeft="@+id/rview01"></TextView><!-- 定义该组件位于rview01组件的左边 --><TextView android:layout_height="wrap_content" android:layout_width="wrap_content"android:id="@+id/rview04"android:background="@drawable/leaf" android:layout_toLeftOf="@+id/rview01" android:layout_alignTop="@+id/rview01" ></TextView><!-- 定义该组件位于rview01组件的右边 --><TextView android:layout_height="wrap_content" android:layout_width="wrap_content"android:id="@+id/rview05"android:background="@drawable/leaf" android:layout_toRightOf="@+id/rview01" android:layout_alignTop="@+id/rview01"></TextView></RelativeLayout>?效果图:
?

2.绝对布局
?
? ? 绝对布局由AbsoluteLayout代表,Android不提供如何布局控制,而是由开发人员自己通过X坐标,Y坐标来控制组件的位置。
?
XML属性说明
?
<?xml version="1.0" encoding="utf-8"?><AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:layout_height="fill_parent"><!-- 定义一个文本框,使用绝对定位 --><TextView android:layout_height="wrap_content" android:layout_width="wrap_content"android:layout_x="20dip"android:layout_y="20dip"android:text="用户名:"></TextView><EditText android:layout_height="wrap_content" android:layout_width="wrap_content"android:layout_x="80dip"android:layout_y="15dip"android:width="200px"></EditText><TextView android:layout_height="wrap_content" android:layout_width="wrap_content"android:layout_x="20dip"android:layout_y="80dip"android:text="密码:"></TextView><EditText android:layout_height="wrap_content" android:layout_width="wrap_content"android:layout_x="80dip"android:layout_y="75dip"android:password="true"android:width="200px"></EditText><Button android:layout_x="130dip"android:layout_y="135dip"android:layout_height="wrap_content" android:layout_width="wrap_content"android:text="登录"/></AbsoluteLayout>?效果图
?
本人开了个充值淘宝网店。有需要的朋友请访问的店铺并拍下所充值的话费,
本店已加入消费保障服务计划,货源来源于淘宝充值平台,安全可靠便捷,
支付过后立即到账

http://xiaowen168.taobao.com