【学习笔记】day2数据存储和界面展现第一天 01_相对布局

来源:互联网 发布:js 判断 arguments 编辑:程序博客网 时间:2024/05/16 06:11

Android中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" >        <Button         android:id="@+id/center"        android:layout_width="100dp"        android:layout_height="wrap_content"        android:text="中间"        android:layout_centerInParent="true"        />    <Button         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="上面"        android:layout_above="@id/center"        android:layout_alignLeft="@id/center"        android:layout_alignRight="@id/center"        />    <Button         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="下面"        android:layout_below="@id/center"        android:layout_alignLeft="@id/center"        android:layout_alignRight="@id/center"        />    <Button         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="左边"        android:layout_toLeftOf="@id/center"        android:layout_alignTop="@id/center"        android:layout_alignBottom="@id/center"        android:layout_alignParentLeft="true"        />    <Button         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="右边"        android:layout_toRightOf="@id/center"        android:layout_alignTop="@id/center"        android:layout_alignBottom="@id/center"        android:layout_alignParentRight="true"        />         <Button         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="左上"        android:layout_toLeftOf="@id/center"        android:layout_above="@id/center"        android:layout_alignParentLeft="true"        />     <Button         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="左下"        android:layout_toLeftOf="@id/center"        android:layout_below="@id/center"        android:layout_alignParentLeft="true"        />     <Button         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="右上"        android:layout_toRightOf="@id/center"        android:layout_above="@id/center"        android:layout_alignParentRight="true"        />     <Button         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="右下"        android:layout_toRightOf="@id/center"        android:layout_below="@id/center"        android:layout_alignParentRight="true"        /></RelativeLayout>


0 0
原创粉丝点击