页面布局:
1. 线性布局 LinearLayout
它包含的子控件将以横向或竖向的方式排列。通俗的说,每个控件参照线的特点,要么是横向的,要么是竖向的
android:orientation=" " horizontal 横向/vertical 竖向
2.框架布局 FrameLayout
3.表格布局 TableLayout
4.相对布局 RelativeLayout
当前控件与兄弟控件或者父控件之间的相对位置,从而达到控制控件位置的目的
①边缘对齐但不会覆盖:
android:layout_above:将该控件的底部置于给定ID的控件之上
android:layout_below:将该控件的底部置于给定ID的控件之下
android:layout_toLeftOf:将该控件的右边缘置于给定ID的控件左边缘
android:layout_toRightOf:将该控件的左边缘置于给定ID的控件右边缘
并且可以叠加,同时下边和右边,即右下
②边缘对齐但是有可能覆盖:
android:layo ut_alignBaseline:将该控件的baseline与给定ID的baseline对齐
android:layout_alignTop:将该控件的顶部边缘与给定ID的顶部边缘对齐
android:layout_alignBottom:将该控件的底部边缘与给定ID的底部边缘对齐
android:layout_alignLeft:将该控件的左边缘与给定ID的左边缘对齐
android:layout_alignRight:将该控件的右边缘与给定ID的右边缘对齐
③ 与父控件对齐:
android:layout_alignParentTop:如果为true,将该控件的顶部与其父控件的底部对齐
android:layout_alignParentBottom:如果为true,将该控件的底部与其父控件的底部对齐
android:layout_alignParentLeft:如果为true,将该控件的左部与其父控件的左部对齐
android:layout_alignParentRight:如果为true,将该控件的右部与其父控件的右部对齐
android:layout_centerHorizontal: 如果为true,将该控件水平居中
android:layout_centerVertical:如果为true,将该控件垂直居中
android:layout_centerInParent:如果为true,将该控件置于父控件的中央
④自定义偏移位置:
自己输入偏移值,而不是固定的位置
android:layout_marginTop:上偏移的值
android:layout_marginBottom:下偏移的值
android:layout_marginLeft:左偏移的值
android:layout_marginRight:右偏移的值
此时是对hello world进行右偏移20dp,即是其有右边有20dp的空位
5.绝对布局 AbsoluteLayout
基础控件:
1.orientation属性 :表示方向
vertical :垂直方向
horizontal :水平方向
2. layout_width属性: 宽度
layout_height属性:高度
Android常用控件
TextView 文本框
android:textStyle="normal" 更改字体
android:paddingTop="100dp" 里面的text输入的字符与顶部的距离
ImageView 图片框
Button 按钮