android的布局文件简介
LinearLayout-线性布局:
LinearLayout-线性布局有两个方向:水平和垂直方向。分别是通过android:orientation="horizontal"和android:orientation="vertical"来控制的
权重,也就是对控件设置 android:layout_weight的属性。这个属性的意思是分配剩余空间。
比如有俩个控件,分别设置为android:layout_weight=“1”,android:layout_weight=“2”,表示控件分别占屏幕的1/3和2/3,。不过这是有一个前提的,就是建立在控件的宽度或者高度设置为0dp的情况下。
例子:
<?xml version="1.0" encoding="utf-8"?>android:orientation="vertical" tools:context=".MainActivity" > android:orientation="vertical" > weight="1" android:orientation="horizontal" >
RelativeLayout-相对布局
相对,顾名思义是有参照的,就是以某个兄弟组件,或者父容器来决定的(兄弟组件是在一个同一个布局里面的组件,如果是布局里一个组件参照另一个布局里的组件会出错)
android:paddingBottom:设置控件内容与控件下边缘的距离
android:paddingTop:设置控件内容与控件上边缘的距离
android:paddingLeft:设置控件内容与控件左边缘的距离
android:paddingRight:设置控件内容与控件右边缘的距离
android:layout_marginBottom:设置此控件的下边缘与其他控件的距离
android:layout_marginTop:设置此控件的上边缘与其他控件的距离
android:layout_marginLeft:设置此控件的左边缘与其他控件的距离
android:layout_marginRight:设置此控件的右边缘与其他控件的距离
ConstraintLayout(约束布局)
ConstraintLayout 能够灵活地定位和调整子View的大小,子 View 依靠约束关系来确定位置。
功能:
- 相对定位 (横向:Left、Right、Start、End ;纵向:Top、Bottom、Baseline(文本底部的基准线))
- 外边距
- 居中和倾向
- 可见性的表现
- 尺寸约束
- Chain
- 辅助工具
一些基本属性:
更多相关文章
- Android 布局 LinearLayout与RelativeLayout的布局属性
- Android UI设计——EditText控件
- 3.EditText控件
- android 相对定位布局方向
- android studio常用控件
- Android图表控件MPAndroidChart——曲线图+柱状图 CombinedChart
- android studio开发 控件布局
- android 布局属性