如何删除褪色线上方的标签下的线?

时间:2011-11-04 11:42:29

标签: android android-tabhost

我正在开发一个使用标签的应用。我想自定义选项卡外观。我想删除选项卡下面出现的一条小线,而不是淡出线。我试过TabHost的很多方法但是无法摆脱它。我想,这很简单,但我找不到方法。

我检查了这个链接:

https://stackoverflow.com/questions/3511596/get-rid-of-the-line-under-tabwidget

How to remove black line from tabbar in Android?

但这解释了删除我不需要的淡化线。

我想删除图片中红色圆圈的线条。我该怎么做?

enter image description here

任何有用的帮助。

编辑:

我的xml文件是:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:background="#FFFFFF"
    android:fadingEdge="none" android:fadeScrollbars="false"
    >
    <LinearLayout android:orientation="vertical"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:padding="5dp">      
        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/title"
        />
        <View
          android:layout_width="fill_parent"
          android:layout_height="5dip" 
        />
        <View
            android:layout_width="fill_parent"
            android:layout_height="2dip" 
            android:background="#9deafa"
            android:paddingLeft="5dip"
            android:paddingRight="5dip"
        />
        <View
            android:layout_width="fill_parent"
            android:layout_height="5dip" 
        />
        <TabWidget android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout android:id="@android:id/tabcontent"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            android:padding="5dp" />        
    </LinearLayout> 

</TabHost>

4 个答案:

答案 0 :(得分:4)

我没有找到一种方法让它在Android 2.1中运行。所以最后我将项目转换为android 2.2,现在摆脱了那条小黑线使用:

  tabHost.getTabWidget().setStripEnabled(false);

答案 1 :(得分:0)

How to remove black line from tabbar in Android?

问题在于使用背景查看属性。

如果为View提供背景,它将在Layout中显示为水平线。

因此请删除背景属性android:background="#9deafa"

    <View
        android:layout_width="fill_parent"
        android:layout_height="2dip" 
        android:paddingLeft="5dip"
        android:paddingRight="5dip"
    />

答案 2 :(得分:0)

非常适合我的工作:

将自定义主题应用于您的活动,并清除 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" ... >

答案 3 :(得分:0)

添加此行 机器人:tabStripEnabled = “假” 在XML文件的TabWidget标记中。

相关问题