开发者

How to have Android tabs coexisting with other views?

I need to have a layout that has a view above a set of tabs. I've gotten the tabs working fine, but as soon as I try to add a view outside of them I'm left with that view and no visible tabs.

This works fine:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabHost 
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1">
        <LinearLayout  ... />

But this doesn't:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView  ... />  <!--  THIS LINE HERE!!!  -->
    <TabHost 
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1">
        <LinearLayout  ... />

What can I do to make my tabs co-exist with other views?


For the sake of completeness, 开发者_Python百科my Activity extends TabActivity.


Mayby you should get rid of the initial LinearLayout and start with your tabhost, like in this tutorial? Or is your goal to have a set-up like the image below?

+-----------------+
| App Title       |
+-----------------+
| some text       |
+-----+-----+-----+
| tab | tab | tab |
+-----+-----+-----+
|                 |


Actually, according to this article, it isn't possible. Grr.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜