Android学习笔记: 第三天

来源:互联网 发布:网络暴力 电影 2011 编辑:程序博客网 时间:2024/06/05 10:07

6. 常用控件

EditText

TextView

Button

Menu


7. 8.  Activity生命周期

onCreate

onStart

onresume

onPause

onStop

onRestart

onDestory


Task


9. Activity布局(一) LinearLayou 和 TableLayout

LinearLayout

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="wrap_content"    android:layout_height="fill_parent"    android:orientation="vertical" >    <TextView        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="@string/hello" />    <TextView        android:id="@+id/firstText"        android:text="第一行"        android:gravity="center_vertical"        android:textSize="35pt"        android:background="#aa0000"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:paddingLeft="10dip"        android:paddingTop="20dip"        android:paddingRight="30dip"        android:paddingBottom="40dip"        android:layout_weight="1"        android:singleLine="true"/>            <TextView         android:id="@+id/secondText"        android:text="第二行"        android:gravity="center_vertical"        android:textSize="15pt"        android:background="#0000aa"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_weight="1"/></LinearLayout>


TableLayout

<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:stretchColumns="0">    <TableRow>        <TextView             android:text="@string/row1_column1"            android:background="#aa0000"            android:padding="3dip" />        <TextView            android:text="@string/row1_column2"            android:padding="3dip"            android:gravity="center_vertical"            android:background="#00aa00" />                <TextView            android:text="@string/row1_column3"            android:gravity="right"            android:background="#0000aa"            android:padding="3dip" />    </TableRow>        <TableRow>        <TextView            android:text="@string/row2_column1"            android:padding="3dip" />        <TextView            android:text="@string/row2_column2"            android:gravity="right"            android:padding="3dip" />    </TableRow></TableLayout>


10. Activity布局(二) LinearLayou 和 TableLayout 的嵌套


11. Activity布局(三)相对布局

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:padding="10px" >        <TextView        android:id="@+id/label"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="Type here:" />        <EditText android:id="@+id/entry"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:background="@android:drawable/editbox_background"        android:layout_below="@id/label" />        <Button android:id="@+id/ok"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/entry"        android:layout_alignParentRight="true"        android:layout_marginLeft="10px"        android:text="OK" />        <Button android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_toLeftOf="@id/ok"        android:layout_alignTop="@id/ok"        android:text="Cancel" />t</RelativeLayout>


原创粉丝点击