cj1098
cj1098

Reputation: 1610

How to add a button above a tabHost layout

So all I want to do is add a button above the tabhost layout...can anyone help me? I've tried several things such as align_bottom, switching views... nothing's worked. If I need to post the code where I'm calling the xml let me know. Here's my xml code:

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

        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button" />

        <TabHost
            android:id="@android:id/tabhost"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
             >
             <TabWidget 
                 android:id="@android:id/tabs"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"></TabWidget>


    <FrameLayout 
        android:id="@android:id/tabcontent"
        android:background="#ffffff"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></FrameLayout>             

    <TextView
        android:id="@+id/view1"
        android:layout_width="match_parent"
        android:layout_height="439dp" ></TextView>



    <TextView
        android:id="@+id/view2"
        android:layout_width="match_parent"
        android:layout_height="344dp" ></TextView>



    <TextView
        android:id="@+id/view3"
        android:layout_width="314dp"
        android:layout_height="match_parent" ></TextView>
    </TabHost>    
    </LinearLayout>

Upvotes: 0

Views: 2303

Answers (1)

Hiral Vadodaria
Hiral Vadodaria

Reputation: 19250

I had the same issue which i could solve by using below code for xml file:

<?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="wrap_content"
              android:padding="5dp">        
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/button"
            android:text="Button"
        />  
        <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="wrap_content"
                 android:padding="5dp" />       
    </LinearLayout> 

</TabHost>

Upvotes: 2

Related Questions