集训day_03

一、5大布局

创建布局:layout右击→New→Layout resource file--------Root element:布局类型

1.线性布局(LinearLayout)

android:textSize="18sp"                   //调整中间中字体大小
match_parent                              //填充父窗体
wrap_content                              //包括内容
android:hint                              //控件上显示的字,一点击就消失
android:layout_marginLeft="20dp"          //控件左侧外边距
android:layout_margin="20dp"              //控件一周边距
android:layout_paddingLeft="20dp"	  //控件左侧内边距

2.相对布局(RelativeLayout)

       

android:layout_below+"@+id/    "		  //此控件在哪个控件的下边,空格就填哪个控件的id
android:layout_above+"@+id/    "		  //在----上边
android:layout_toLeftOf+"@+id/    "		  //在----左边
android:layout_toRightOf+"@+id/    "    	  //在----右边

3.帧布局(FrameLayout)

        一层一层的,例:视频播放器,暂停后屏幕中间的播放按钮

android:layout_gravity="center_vertical" 		  //垂直居中
android:layout_gravity="center_horizontal" 	          //水平居中
android:layout_gravity="center" 	 	          //水平、垂直均居中

4.表格布局(TableLayout)

      一个TableRow标签就代表一行

<TableRow>                                           //第一行
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="哈哈"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="嘿嘿"
        android:layout_marginLeft="20dp"
        />
</TableRow>
<TableRow>                                           //第二行
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="哈哈"
        />
</TableRow> 

5.绝对布局(AbsoluteLayout)

      控件位置固定,后期做屏幕适配不容易做,基本被废弃。

二、Android中的单位

1.sp:给一个textview设置字体大小

2.dp:其他情况单位全用dp,比如设置控件边距

三、日志猫

Log.v(tag,"要打印的内容")    --------蓝色(v级别)
Log.i(tag,"要打印的内容")    --------绿色(info级别)
Log.d(tag,"要打印的内容")    --------黑色(debug级别)
Log.w(tag,"要打印的内容")    --------黄色(warn级别)
Log.e(tag,"要打印的内容")    --------红色(error级别)
System.out.println();       --------绿色

猜你喜欢

转载自blog.csdn.net/depths_p/article/details/81151987