Reputation: 1642
I have a TabHost layout (the below code)
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myTabHost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="65dp" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="65dp" >
<LinearLayout
android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
</FrameLayout>
</TabHost>
I am loading some activities inside the TabHost and every things about the activities are OK. but my problem is about loading another layout at the top of TabHost via Include tag,
in other layouts like LinearLayout i put a include tag inside it and it was OK, but in TabHost i could not do like that because after adding include the TabHost UI gets corrupted
.
please tell me how to solve this problem
Upvotes: 0
Views: 951
Reputation: 37729
Wrap your TabHost
tag with another LinearLayout
tag like this:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- inclde goes here -->
<TabHost
android:id="@+id/myTabHost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Other tags as you have already. -->
</TabHost>
</LinearLayout>
Upvotes: 2
Reputation: 7626
Then Place the LinearLayout
as a parent to TabHost
and include that LinearLayout
using include tag in other layouts
as below:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TabHost
android:id="@+id/myTabHost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="65dp" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="65dp" >
<LinearLayout
android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
</FrameLayout>
</TabHost>
</LinearLayout>
Upvotes: 1