Android开发总结笔记 RelativeLayout(相对布局) 1-1-2
来源:互联网 发布:淘宝口令转换 编辑:程序博客网 时间:2024/04/29 18:06
RelativeLayout的继承结构
相对布局,顾名思义就是相对于某个组件而摆放的位置。所以,相对布局的常用属性都与这个“相对”有关(RelativeLayout API)
下面演示这几个常用属性的方法
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:id="@+id/android"
android:layout_centerInParent="true"
android:background="@mipmap/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<!-在android的左边->
<ImageView
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher" />
<!-在android的右边->
<ImageView
android:layout_centerVertical="true"
android:layout_toRightOf="@id/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher" />
<!-在android的上边->
<ImageView
android:layout_centerHorizontal="true"
android:layout_above="@id/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher" />
<!-在android的下边->
<ImageView
android:layout_centerHorizontal="true"
android:layout_below="@id/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher" />
</RelativeLayout>
效果图
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:layout_centerInParent="true"
android:background="@mipmap/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher" />
<ImageView
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher" />
<ImageView
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher" />
<ImageView
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher" />
</RelativeLayout>
效果图
0 0
- Android开发总结笔记 RelativeLayout(相对布局) 1-1-2
- Android笔记---RelativeLayout相对布局
- Android布局RelativeLayout(相对布局)笔记
- android开发4:布局管理器1(线性布局,相对布局RelativeLayout-案例)
- Android学习笔记08:相对布局RelativeLayout
- Android学习笔记(14):相对布局RelativeLayout
- 【Android 开发教程】RelativeLayout相对布局
- Android开发重点难点:RelativeLayout(相对布局)详解
- Android 相对布局:RelativeLayout
- android 相对布局RelativeLayout
- android 相对布局 RelativeLayout
- Android相对布局(RelativeLayout)
- Android--RelativeLayout相对布局
- Android RelativeLayout相对布局
- Android相对布局RelativeLayout
- Android 相对布局 RelativeLayout
- Android RelativeLayout 相对布局
- Android相对布局(RelativeLayout)
- 潘鹏整理WPF(6)带标题的内容控件GroupBox&&Expander&&TabControl
- 【VBS教程3】:VBS如何激活指定窗口
- C++基础
- 图文:eclipse中SVN分支合并到主干
- 猴子吃桃子
- Android开发总结笔记 RelativeLayout(相对布局) 1-1-2
- 点击EDITTEXT之外 隐藏输入法的实现
- PopupWindow实现右侧、左侧和底部弹出菜单
- android学习之路(五)----stetho显示不出调试信息
- requestWindowFeature()的应用
- 数据结构【线性表(二)链表】项目一--建立单链表
- 判断Android手机是否开启USB调试
- LINUX文件锁定
- Oracle Jdbc 防sql注入