Frage

I know this is a bit odd but bear with me.

I have a custom view, that extends TabHost and inflates a XML. It includes several views, it is aligned to bottom and everything works great.

The problem is when I put the TabHost in a different activity, where I don't want to see any of the TabHost views. Only the TabHost tabs on top of the activity layout. Basically, I want the TabHost to be there as a disabled bottom bar.

here's the TabHost XML (which works great and aligned to bottom, as long as I toggle between one of the custom views):

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <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"
             >

            <CustomView#1
                android:id="@+id/tab_watch_me"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <CustomView#2
                android:id="@+id/tab_messages"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <CustomView#3
                android:id="@+id/tab_search_results"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <CustomView#4
                android:id="@+id/tab_my_profile"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <CustomView#5
                android:id="@+id/tab_user_profile"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
         </FrameLayout>

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0" />
    </LinearLayout>

</TabHost>

Here's the activity XML (the one that I don't want the tabhost views to be shown, only to align the tabhost buttons to the bottom):

<?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="match_parent"
    android:orientation="vertical" >

    <customview.HeaderView
        android:id="@+id/header_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

**//Notice that I don't want to show any of the customViews the tabhost hold. only the tabhost tabs/buttons**

    <customview.MyTabHost
        android:id="@+id/settings_tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

Let me know if you need more code in order to help!

Thank you!

War es hilfreich?

Lösung

My RelativeLayout solution in case this helps anyone. I'm still looking for a better solution if anyone has to offer.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <customview.HeaderView
        android:id="@+id/header_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" />

<Any other view
android:layout_below="@+id/header_view"
/>

    <customview.MyTabHost
        android:id="@+id/settings_tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true" />

</RelativeLayout>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top