Main.XML <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <RelativeLayout android:id="@+id/Relativelayout01" android:background="@drawable/head_bg" android:layout_width="fill_parent" android:layout_height="42dp"> <ImageButton android:id="@+id/a" android:layout_width="36dp" android:layout_height="27dp" android:layout_toLeftOf="@id/Relativelayout01" android:src="@drawable/back" android:layout_marginTop="10dp" /> <ImageButton android:id="@+id/b" android:layout_width="125dp" android:layout_height="27dp" android:layout_centerInParent="true" android:src="@drawable/logo" /> <ImageButton android:id="@+id/c" android:layout_width="48dp" android:layout_height="27dp" android:layout_alignParentRight="true" android:src="@drawable/login" android:layout_marginTop="10dp" /> </RelativeLayout> </LinearLayout>
RelativeLayout用到的一些重要的属性:
第一类:属性值为true或false
android:layout_centerHrizontal 水平居中
android:layout_centerVertical 垂直居中
android:layout_centerInparent 相对于父元素完全居中
android:layout_alignParentBottom 贴紧父元素的下边缘
android:layout_alignParentLeft 贴紧父元素的左边缘
android:layout_alignParentRight 贴紧父元素的右边缘
android:layout_alignParentTop 贴紧父元素的上边缘
android:layout_alignWithParentIfMissing 如果对应的兄弟元素找不到的话就以父元素做参照物
第二类:属性值必须为id的引用名“@id/id-name”
android:layout_below 在某元素的下方
android:layout_above 在某元素的的上方
android:layout_toLeftOf 在某元素的左边
android:layout_toRightOf 在某元素的右边
android:layout_alignTop 本元素的上边缘和某元素的的上边缘对齐
android:layout_alignLeft 本元素的左边缘和某元素的的左边缘对齐
android:layout_alignBottom 本元素的下边缘和某元素的的下边缘对齐
android:layout_alignRight 本元素的右边缘和某元素的的右边缘对齐
第三类:属性值为具体的像素值,如30dip,40px
android:layout_marginBottom 离某元素底边缘的距离
android:layout_marginLeft 离某元素左边缘的距离
android:layout_marginRight 离某元素右边缘的距离
android:layout_marginTop 离某元素上边缘的距离
相关推荐
1.使用RelativeLayout+TextView底部导航栏样式。 2.右上角带有消息提示个数。 3.使用Fragment实现导航效果。 相应的博客地址为:https://blog.csdn.net/lpCrazyBoy/article/details/80886487
一个Android XML布局的例子,主要利用xml文件进行布局,里边用到的是RelativeLayout。具体的本例中: 非洲草原地图:用到了FrameLayout的使用;ActivityMain演示了linerLayout。 个性化表单ActivityLayout 演示...
android实现自定义RelativeLayout可拖动、缩放、旋转TextView
介绍了android 中 RelativeLayout 下的各种属性。linux下打开.
Android 相对布局 RelativeLayout 属性
Android RelativeLayout 的翻译应用。希望能给大家帮助
Android相对布局RelativeLayout的基本用法,相对布局是最实用的布局。
自己写的android相对布局demo,具体参照博客
介绍一下RelativeLayout的一些属性,针对于刚学习android开发的朋友
android布局属性RelativeLayout详解.
RelativeLayout使用详解 包括属性方法详解 实现LinearLayout中weight属性 用 RelativeLayout实现计算器界面 具体参见博客 http://blog.csdn.net/a87b01c14/article/details/49466325
底部导航栏我选择用FragmentTabHost+Fragment来实现,这个方法我觉得挺好用的,代码量也不多 首先是开始的activity_main.xml <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android ...
Android中使用RelativeLayout布局完成的登录练习题要求说明.pdf 学习资料 复习资料 教学资源
自定义RelativeLayout圆角图片背景,自定义属性 背景 圆角半径
LinearLayout和RelativeLayout实现精确布局-简单版 类似与应用评价
主要介绍了Android实现图片叠加效果的两种方法,结合实例形式分析了Android实现图片叠加效果的两种操作方法与相关注意事项,需要的朋友可以参考下
Android RelativeLayout骏丰频谱水实例+源码下载,骏丰频谱水的开发实例,仅供参考
DragView 可拖拽的view,继承自RelativeLayout
RelativeLayout 上 下 中 左 右布局 demo
android 自定义右上角为关闭按钮X的dialog,其中X是文字按钮。是在网站上不可用的基础上,用RelativeLayout 改的。