2013-05-08 70 views
7

我正在使用TabWidget,并且我在TabActivity和Tabs之间得到一个空白区域。Android TabWidget空白问题

我不知道如何删除这个空格请任何一个可以帮助我,我应该如何删除它,我tab_main.xml如下:

<?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> 

我试着将TabWidget的背景颜色设置为android:color:transparent,但Activity和Tab之间仍有相同的空白。

我不希望我的活动和标签之间的任何分离空间(是否有可能做到这一点?)

请任何一个可以建议我如何摆脱这一空白的。

enter image description here

+0

您是否试图将“TabWidget”的高度设置为0dp,类似于框架布局?另外,如果你的目标是API 8或更多,你应该使用'match_parent'而不是fill。 – TronicZomB 2013-06-06 14:42:33

回答

0

它看起来就像你有我在我的项目有类似的问题,请this项目,并尝试实现可绘制的xml文件并为您的TabWidget提供该项目中给出的特定自定义维度。它一定会为你工作。

+0

它为我工作感谢您的帮助! – iOSBee 2013-06-07 10:27:40

1

你出最有可能的输出提出了一种保证金/填充错误,而不是一个布局错误。您的TabWidget或您的FrameLayout的边距可能会被您使用的整体主题继承。

最有可能下面将解决这个问题(注意额外的保证金/填充样式):

 <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" 
      .... 
      .... /> 

你的FrameLayout也可能有其中有一个保证金/填充任何嵌套组件,以及这反过来又可能导致白色的空间。我已将android:background添加到FrameLayout和TabWidget中,只是为了帮助诊断如果两者之间有空白时进行故障诊断。

你说你已经试着把TabWidget的背景颜色设置为透明 - 但它没有帮助,因为如果有一个边距 - 那么底层活动的背景颜色在透明区域下面显示为白色。如果您将整体RelativeLayout的背景色设置为蓝色 - 那么您将看到蓝色即将通过。所以修正边缘/填充而不是试图隐藏它。

0

从您的屏幕截图看,您似乎正在使用WebViewWebview附带默认marginpadding> 0.您可以通过覆盖WebView'sbody标记或使用csspaddingmargin设置为零。

有关详细信息,请参阅回答下列SO问题:

Remove unwanted white space in webview