将慢慢更新。。。慢慢摸索Android的xml布局标签与html布局标签的相似。
1.xml里面的LinearLayout相当于html的div。
因为RelativeLayout的布局相对来说比较自由,下面尝试在相对布局(RelativeLayout)xml下使用LinearLayout。
看代码时,可以把LinearLayout 看成div
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:id="@+id/info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/xm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓名:"
android:textSize="18dp"/>
<EditText
android:id="@+id/shuru_xm"
android:layout_weight="0.7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/xh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="学号:"
android:textSize="18dp"/>
<EditText
android:id="@+id/shuru_xh"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:id="@+id/xb_xuanze"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/info">
<TextView
android:id="@+id/xb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="性别:"
android:textSize="18dp"/>
<RadioGroup
android:id="@+id/xb_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<RadioButton
android:id="@+id/nanhai"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="男"
android:textSize="18dp"/>
<RadioButton
android:id="@+id/nvhai"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女"
android:textSize="18dp"/>
</RadioGroup>
</LinearLayout>
<LinearLayout
android:id="@+id/mz_xuanze"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/xb_xuanze">
<TextView
android:id="@+id/mz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="民族:"
android:textSize="18sp"/>
<Spinner
android:id="@+id/mz_lb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"/>
</LinearLayout>
</RelativeLayout>
这里只是讲xml布局标签与html布局标签的div相似而已。可以根据这种方式来继续写学生管理界面。
为避免作业相似,改日附上网格布局学生管理界面、表格布局学生管理界面demo。