Problem with Android TabWidget White Space

I am working on TabWidget and I get a space between TabActivity and tabs.

I don’t know how to remove this space, please someone can help me how to remove it, my tab_main.xml looks like this:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" /> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" /> </LinearLayout> </TabHost> 

I tried to put the background color of the TabWidget in android: color: transparent, but still the same space runs between the activity and the tab.

I do not need to share the space between my activity and tabs (is it possible to do this?)

Please, anyone can suggest me how to get rid of this gap.

enter image description here

+7
source share
3 answers

It looks like you have the same problem as mine in my project, look at this project and try to implement popped XML files and provide your TabWidget with specific user parameters specified in this project. This will definitely work for you.

0
source

The result you showed most likely indicates a Margin / Padding error, and not a layout error. Either your TabWidget or your FrameLayout can have inheritance inherited by the common theme that you use.

Most likely, this will fix the problem (pay attention to additional styles of fields / additions):

  <FrameLayout android:layout_marginBottom="0dip" android:layout_paddingBottom="0dip" android:background="@android:color/holo_green_light" android:id="@android:id/tabcontent" .... .... /> <TabWidget android:layout_marginTop="0dip" android:layout_paddingTop="0dip" android:background="@android:color/holo_blue_light" android:id="@android:id/tabs" .... .... /> 

Your FrameLayout can also have any nested components that have margin / padding and which, in turn, can cause spaces. I added android:background for both FrameLayout and TabWidget to help troubleshoot if there is a space between them.

You said that you tried to put the background color of the TabWidget in transparent, but this will not help, because if there is a margin, then the main background color of the action is displayed as white, below the transparent area. If you set the overall background color of the RelativeLayout to something like cyan, then you will see how blue goes. Therefore, fix margin / padding, and do not try to hide it.

+1
source

From your screenshot, it looks like you are using WebView . WebView comes with a default margin and padding > 0. You can set padding and margin to zero by overriding the WebView's body tag or using css .

For more details see the answers to the following question:

Remove unwanted white space in a web browser

0
source

All Articles