获取下TabWidget摆脱线TabWidget

2023-09-12 09:10:10 作者:不帅你报警

我有简单的选项卡活动:

I've got simple tab activity with next layout:

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

我使用的按键作为指标标签

I use buttons as indicators for tabs

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总是有黑线和阴影在上面的效果(你可以看到它在按键):

In this case FrameLayout always got black line and shadow effect on top (you can see it under buttons):

现在的问题是:我怎样才能摆脱这一行的?哪里是绘制它的Andr​​oid源的方法是什么?

推荐答案

应用自定义主题的活动,并空出了android:windowContentOverlay属性

Apply a custom theme to your activity, and null out the android:windowContentOverlay attribute.

定义一个主题的themes.xml:

Define a theme in themes.xml:

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

应用在AndroidManifest.xml中对应用程序的主题或活动:

Apply the theme on your application or the activity in AndroidManifest.xml:

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

希望它帮助。这引起了我很多头疼...

Hope it helps. It caused me lots of headache...