一些关于RelativeLayout属性的用法
16lz
2021-01-23
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 距离指定元素顶部的距离
第一类:属性值为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 距离指定元素顶部的距离
更多相关文章
- Android ListView Adapter的getItemViewType和getViewTypeCount
- Android 自定义View及其在布局文件中的使用示例(二)
- android布局属性总结备用
- 我的Android之旅——UI界面六大布局之认识布局(一)
- RelativeLayout的布局学习(部分知识点)