相对布局中的属性的运用

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" >    <!-- RelativeLayout:相对布局;子控件相对父容器;子控件相对兄弟控件 -->    <!-- 相对属性不设置控件默认位置在父容器左上角 -->    <!-- 子控件相对父容器属性: -->    <!-- layout_alignParentRight:相对于父容器右侧 -->    <!-- layout_alignParentBottom:相对于父容器底部 -->    <!-- layout_alignParentLeft:相对于父容器左侧 -->    <!-- layout_alignParentTop:相对于父容器顶部 -->    <!-- layout_centerInParent:垂直水平居中 -->    <!-- layout_centerVertical:垂直居中 -->    <!-- layout_centerHorizontal:水平居中 -->    <TextView  android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentRight="true" android:background="#000fff" android:text="right|top" />    <TextView  android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentBottom="true" android:background="#fff000" android:text="left|bottem" />    <TextView  android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentLeft="true" android:background="#000fff" android:text="Left|Top" />    <TextView  android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:background="#fff000" android:text="right|bottem" />    <TextView  android:layout_width="50dp" android:layout_height="50dp" android:layout_centerInParent="true" android:background="#f0f0f0" android:text="center" />    <TextView  android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:background="#0f0f0f" android:text="top|horizontal" android:textColor="#ffffff" />    <TextView  android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:background="#00ffff" android:text="left|vertical" />    <TextView  android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:background="#fffff0" android:text="right|vertical" />    <TextView  android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:background="#fff000" android:text="bottem|horizontal" /></RelativeLayout>
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" >    <!-- id:使用具体控件前提:@+id/在给控件声明新id时使用;@id/使用已有的id -->    <!-- layout_toLeftOf:在哪个兄弟控件的左侧 -->    <!-- layout_toRightOf:在哪个兄弟控件的右侧 -->    <!-- layout_above:在哪个兄弟控件的上边 -->    <!-- layout_below:在兄弟控件下边 -->    <TextView  android:id="@+id/centerTv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="#000fff" android:text="center" android:textColor="#ffffff" />    <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@id/centerTv" android:text="left" />    <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toRightOf="@id/centerTv" android:text="right" />    <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/centerTv" android:layout_centerHorizontal="true" android:text="top" />    <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/centerTv" android:layout_centerHorizontal="true" android:text="bottem" /></RelativeLayout>
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" >    <!-- layout_alignLeft:相对于兄弟控件左对齐 -->    <!-- layout_alignRight:相对于兄弟控件右对齐 -->    <!-- layout_alignTop:相对于兄弟控件顶部对齐 -->    <!-- layout_alignBottom:相对于兄弟控件底部对齐 -->    <TextView  android:id="@+id/centerTv" android:layout_width="50dp" android:layout_height="50dp" android:layout_centerInParent="true" android:background="#00ffff" android:text="center" />    <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@id/centerTv" android:text="left" />    <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignRight="@id/centerTv" android:text="right" />    <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@id/centerTv" android:text="bottem" />    <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignTop="@id/centerTv" android:text="top" />    <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@id/centerTv" android:layout_toRightOf="@id/centerTv" android:text="base" /></RelativeLayout>

更多相关文章

  1. Android(安卓)UI控件详解-SeekBar(拖动条)
  2. Android(安卓)UI控件详解-GridView(网格视图)
  3. android之布局xml各种控件属性详解
  4. Android中Handler的使用
  5. Android中使用SurfaceView视频播放器
  6. android之SeekBar控件用法
  7. 自定义View ----QQ5.0左边侧滑 + 动画
  8. Android(安卓)VideoView播放视频
  9. Android搜索框自动提示文本框——(单一提示)

随机推荐

  1. android CVE 漏洞汇总
  2. Android(安卓)Widget桌面组件创建
  3. SharedPreferences 数据存储
  4. Android(安卓)关闭软键盘
  5. Android获取系统当前时区
  6. android webview实现拍照
  7. 【Android】Native RTL support in Andro
  8. Android_通过传感器抓小偷
  9. 如何在G1上安装非android market的apk
  10. Android(安卓)SDK版本号 与 API Level 对