2013-05-08 86 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