语句解释:
|- 在构建TabHost控件时,最少要使用如下三个标签:
|- <TabHost>标签:描述TabHost控件本身。
|- <TabWidget>标签:描述选项卡集合。
|- <FrameLayout>标签:描述帧布局。
|- TabHost控件要求:
|- 其内的TabWidget和FrameLayout的id属性必须为:
|- @android:id/tabs和@android:id/tabcontent 。
|- 因为在用户操作TabHost时, TabHost内部需要根据用户点击的“选项卡”来控制TabWidget的当前状态以及FrameLayout所需要显示的内容。
<TabHost android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tabhost"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <!-- 将选项卡集合放到最底部 --> <TabWidget android:layout_width="match_parent" android:layout_height="60dp" android:layout_alignParentBottom="true" android:id="@android:id/tabs" /> <!-- 将帧布局放到选项卡的上部--> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="60dp" android:id="@android:id/tabcontent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="个人信息" android:id="@+id/a" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="系统" android:id="@+id/b" /> </FrameLayout> </RelativeLayout> </TabHost> |