布局管理器
线性布局(LinearLayout)
相对布局(RelativeLayout)
LinearLayout
常用属性:
android:id(标识,找到空间):@+id(创造ID)
android:layout_width(宽度):50dp(dp:比例单位,与屏幕大小无关),match_parent(匹配父空间),wrap_content(包含内容)
android:layout_height(高度)
android: background(背景):颜色等属性
android: layout_margin(外边距):有marginTop等详细属性
android:layout_padding(内边距):有paddingTop等详细属性
android:orientation(方向):vertical和horizontal两种
android:gravity:center(居中),center_vertical(竖直居中),center_horizontal(水平居中)
android:layout_weight:在固定值(dp)以后,按比例平分



RelativeLayout
常用属性:
LinearLayout有的大部分都有,但是没有orientation。
android:layout_toLeftOf:在XX左边
android:layout_toRightOf:在XX右边
android:layout_alignBottom:和XX底部对齐对齐
android:layout_alignParentBottom:和XX父空间底部对齐
android:layout_below:在XX下面




本文介绍了两种常见的布局管理器——线性布局(LinearLayout)与相对布局(RelativeLayout)。详细讲解了它们各自的属性及其用法,例如 LinearLayout 的 orientation 属性用于设置布局的方向,而 RelativeLayout 则提供了布局元素之间的相对位置设置。
1566

被折叠的 条评论
为什么被折叠?



