考试知识点(Android 闭卷考试)1
理解 Android 常见的几种布局
几种布局的高和宽,制定LinearLayout,线性布局,布局中的控件在线性方向上依次排列
默认控件水平方向排列
android:orientation=”horizontal”android:orientation=”vertical” 注意:当是水平方向排列,控件宽度不能设立为android:layout_width="match_parent"否则控件会把水平方向沾满,其他控件无法会控件覆盖(无法放置)当是垂直方向,内部控件不能将 android:layout_height="match_parent"指定为 match_parent android:layout_weight="1",使用比例方式来指定控件的大小RelativeLayout,相对布局,是通过相对定位的方式让布局中控件可以出现在布局的任何位置
内部控件,三种属性, 属性值是 true 或 false android:layout_centerHrizontal 水平居中,属性值是”@id/*“ android:layout_below 在某元素的下方属性值是数值 android:layout_marginLeft 离某元素左边沿的距离FrameLayout,帧布局,简朴,应用场景少,和碎片一起使用,没有定位方式,所有控件默认在布局的左上角,后面的会覆盖前面的
每一个组件都代表一个画面用该布局可以实现动画效果PercentFrame(Relative)Layout 比例布局:布局中可以不用wrap_content,match_parent 等方式来指定控件的大小,直接指定控件所占的比例,实现平分布局甚至任意比例分割布局
注意比例布局需要添加库依赖 support:percent:24
由于 LinearLayout 自身