早在ITOO中我们觉得页面代码太多而各种抽页面,像公共的按钮、搜索框、表格等,在主页面中只需要写几句代码就可以了,其实语言都是一样的,在安卓的世界中也是可以抽出部分视图的,只不过在安卓的开发环境中,是通过xml中复用代码来实现的而已——include标签。
在最近做的一个互联网项目中,因为我的任务是要做有四个页面的左右滑屏效果,上面的标题和tab条都是一样的,不同的只是左右滑屏时下面的显示内容,所以就抽出两个界面文件,对主界面进行分割。
include标签:
<include layout="@layout/otherlayout"></div>
首先我们先来看分割出来的页面:
teacher_top:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical" >
<LinearLay