开发者

Is it possible to add header to TabHost in android?

开发者 https://www.devze.com 2023-02-27 03:38 出处:网络
开发者_JAVA技巧Is it possible to add header to TabHost in androidI\'m pretty sure you can, but can\'t test it for you. If you look at the manual you see an xml example:

开发者_JAVA技巧Is it possible to add header to TabHost in android


I'm pretty sure you can, but can't test it for you. If you look at the manual you see an xml example:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>

I suggest you add your header view above the TabHost part, so something like

<?xml version="1.0" encoding="utf-8"?>
<yourView goes here/>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    [....]
</TabHost>

It would be quick to try it out :)


i have an error when i try that . At the start of tabHost.

<?xml version="1.0" encoding="utf-8"?>

<com.dnielf.hello.compounds.Header
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:scrollbars="vertical"
android:textColor="@color/header_text"
android:fadingEdge="vertical"
android:text="Cevichito4Dummies"
android:textStyle="bold"
android:typeface="sans"/>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>  

SOLUTION : the solution was wrap all with a linearlayout ( include its attributes )

0

精彩评论

暂无评论...
验证码 换一张
取 消