2010-08-18 49 views
12

下襬脫了線的我得到了與下一個簡單的佈局選項卡活動:TabWidget

<TabWidget 
    android:id="@android:id/tabs" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"     
    android:background="#ffffff00"  /> 

<FrameLayout    
    android:id="@android:id/tabcontent" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"  
    android:background="#ffffff00"   /> 

我使用的按鈕作爲標籤

tabHost.addTab(tabHost.newTabSpec("Tab1") 
       .setIndicator(new Button(this))     
       .setContent(new Intent(this, TabActivity1.class))); 

tabHost.addTab(tabHost.newTabSpec("Tab2") 
       .setIndicator(new Button(this))     
       .setContent(new Intent(this, TabActivity2.class))); 

在這種情況下,指標的FrameLayout總是有黑線和陰影在上面的效果(你可以看到它下面的按鈕):

alt text

問題是:我該如何擺脫這條線?在Android資源中繪製它的方法在哪裏?

回答

17

應用自定義主題,以您的活動,並空出了android:windowContentOverlay屬性。

中的themes.xml定義一個主題:

<style name="YourTheme" parent="if you want"> 
    ... 
    <item name="android:windowContentOverlay">@null</item> 
    ... 
</style> 

應用的主題在你的應用程序或活動在AndroidManifest.xml:

<application android:theme="@style/YourTheme" 
    ... > 

希望它能幫助。它引起我很多頭痛...

+2

雖然這也爲當前活動刪除了窗口內容疊加層。有沒有辦法只刪除標籤主機的意圖覆蓋? – 2010-12-07 15:14:59

+2

工程就像一個魅力! – rogcg 2011-08-23 19:37:11

+0

完美解決方案! – vanleeuwenbram 2012-01-30 12:13:44

0

看來,這樣做的方法是窩在一個LinerLayout的tabwidget ... 看here.

+0

這不是我的情況。他在TabWidget上談論線路,但我會談論有關RelativeLayout的線路。即使我把TabWidget放到底部,RelativeLayout也會始終有這條線和陰影。 – 2010-08-18 13:00:53

+0

你說的是標籤下方的黑線? – Sephy 2010-08-18 13:47:01

+0

是的。即使我在FrameLayout和TabWidget之間放置了一些東西,這條線也會放在FrameLayout上。 – 2010-08-20 07:56:15

0

可惜你不能擺脫它。這是如何實現TabWidget的結果。內部TabWidgetActivityGroup,每個選項卡的內容是它自己的Activity

8

在你的佈局XML:

<TabWidget ... 
    android:tabStripEnabled="false" > 

... 

</TabWidget> 
+0

沒有工作。實際上在FrameLayout上而不是在TabWidget上。 – 2010-08-30 07:41:54

+4

android:tabStripEnabled僅適用於2.2 – Eby 2010-10-18 12:03:03