views:

2073

answers:

2

I’m taking the HelloTabWidget Android example and trying two things:

  • Moving the tabs to the bottom vs. the top (if that’s even desirable from an Android UI POV)
  • Making each tab show a particular WebView in the space above

I’ve got this for a layout (high level):

<TabHost>
  <LinearLayout>
    <FrameLayout>
      <WebView/>
      <WebView/>
      <WebView/>
      <WebView/>
      <WebView/>
    </FrameLayout>
    <TabWidget/>
  </LinearLayout>
</TabHost>

Everything has a width/height set to fill_parent except for the TabWidget which has its layout_height set to wrap_content (and the layout_gravity set to bottom).

First thing I noticed is that WebViews don’t show anything until all the parents have width/height set to fill_parent. However, once I do that, they fill the entire display, obscuring the TabWidget.

Is there some other trick to making these two views play nicely together?

A: 

AFAIK, tabs will not work at the bottom.

TabHost and WebView work fine together, but in my samples I:

  • Have the TabWidget on the top
  • Do not have the LinearLayout
  • Have 65dip of padding to the top of the FrameLayout, to reserve room for the TabWidget

You can see an example of this in the source code to one of my books, which can be downloaded from that link. Look for Activities/IntentTab in the source code ZIP file.

CommonsWare
Ahh, I see what you mean about the gravity=“bottom” not working out. Also, it doesn’t look correct with the tab direction. I moved it back to the top and … everything works! I didn’t even need any padding. I’ll look at your code sample as well. Thanks!!!
Joe D'Andrea
Actually, it's good to know that the LinearLayout avoids the padding issue. Once upon a time, I don't think that worked. Thanks!
CommonsWare
A: 

CommonsWare, I dont see any xml file which has a webview defiend or any tabhost which has webview as tabcontent. All I see is java class which is using intent to communicate. Can you please specify correct location or am I doing something wrong.

androidProgrammer