tags:

views:

83

answers:

1

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.

+2  A: 

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

Mathias Lin
The guide http://developer.android.com/resources/tutorials/views/hello-tabwidget.html said: "The TabHost must be the root node for the layout"This confused me. Does TabHost have to be the root of XML?
You are right. I can add any other layout above TabWidget in XML to put that layout above tab layout.
I don't know why they say that in the tutorial, maybe it was just meant for their tutorial sample. You can put it anywhere you like. Furthermore, your activity can but doesn't necessarily need to extend from TabActivity. I use tabs this way in a regular activity as well, not as root element.
Mathias Lin