自定义TabHost

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" >
        </FrameLayout>
<!--    在tabWeiget首先就要android:layout_width="fill_parent" ,不然就会包裹内容-->
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/maintab_toolbar_bg"
                android:orientation="horizontal" >

                <TextView
                    
                    android:background="@drawable/home_bar_bg"
                    android:gravity="center_horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.0"
                    android:clickable="true"
                    android:drawableTop="@drawable/icon_home"
                    android:text="首页" />

                <TextView
                     android:background="@drawable/home_bar_bg"
                    android:gravity="center_horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.0"
                    android:clickable="true"
                    android:drawableTop="@drawable/icon_meassage"
                    android:text="信息" />

                <TextView
                     android:background="@drawable/home_bar_bg"
                    android:gravity="center_horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.0"
                    android:clickable="true"
                    android:drawableTop="@drawable/icon_selfinfo"
                    android:text="我的资料" />

                <TextView
                     android:background="@drawable/home_bar_bg"
                    android:gravity="center_horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.0"
                    android:clickable="true"
                    android:drawableTop="@drawable/icon_square"
                    android:text="搜索" />

                <TextView
                     android:background="@drawable/home_bar_bg"
                    android:gravity="center_horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.0"
                    android:clickable="true"
                    android:drawableTop="@drawable/icon_more"
                    android:text="更多" />
            </LinearLayout>
        </TabWidget>
    </LinearLayout>

</TabHost>

你可能感兴趣的:(android,布局)