ITeye博客

一些关于RelativeLayout属性的用法

don_android · 2011-09-24 15:38 · Android——Layout · 移动开发 · Markdown

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_alignBottom 布局与指定元素底部对齐 android:layout_alignLeft 布局与指定元素左边对齐 android:layout_alignRight 布局与指定元素右边对齐

第三类:属性值为具体的像素值,如30dip,40px android:layout_marginBottom 距离指定元素底部的距离 android:layout_marginLeft 距离指定元素左边的距离 android:layout_marginRight 距离指定元素右边的距离 android:layout_marginTop 距离指定元素顶部的距离

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。