简体   繁体   中英

Can I embed Tab Layout into other layout?

Can I embed Tab Layout into other layout?

The designed layout is like below:

Root LinearLayout (vertical oritentation)
   A ViewLayout
   A TextLayout
   A Tab layout
   A View Layout
   A TextLayout

I just want to have tabs in my layout but not the root. Is it possible?

Thanks.

Your problem is that the tabHost isn't root. See this code - it puts the element above the tabs...

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@android:id/tabhost"
    style="@style/page" >

    <RelativeLayout style="@style/page" >

       <RelativeLayout
            android:id="@+id/rell"
            android:layout_width="360dp"
            android:layout_height="66dp" >

            <ImageView
                android:layout_width="211dp"
                android:layout_height="64dp"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:src="@drawable/semple_img" />
        </RelativeLayout> 

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="61dp"
            android:layout_below="@id/rell">
               </TabWidget>

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_below="@android:id/tabs" >
        </FrameLayout>
    </RelativeLayout>

</TabHost>

Yes, it's possible. In your xml you simply put the tabhost wherever you want it. You're having difficulties with the xml?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM