【问题标题】:How to remove line under tab,above the fading line?如何在标签下删除线,在褪色线上方?
【发布时间】:2014-03-18 20:26:40
【问题描述】:

我正在开发一个使用标签的应用程序。我想自定义标签外观。我想删除标签下出现的一条小线,而不是褪色线。 TabHost 的很多方法都试过了,都摆脱不了。我想,很简单,就是找不到方法。

我检查了这个链接:

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

How to remove black line from tabbar in Android?

但这解释了删除褪色线,我不需要。

我想删除图片中红圈内的线,我该怎么做?

任何帮助appriciated。

编辑:

我的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>

【问题讨论】:

  • @Paresh Mayani:我已经完成了,但它解释了删除所有选项卡下的褪色线。我只需要删除它上面的那个。
  • 向我们展示您的标签小部件代码。
  • @Yashwanth Kumar:我尝试根据 SO 上的答案以编程方式使用 tabhost.setStripeEnabled() 来做到这一点,但我在那里没有找到任何这样的方法。我使用的是 android 2.1,所以我想,它不受支持。
  • @Yashwanth Kumar:但它是否还需要,尽管我对在那里删除这条线一无所知?它只是正常编码,标签可绘制几乎没有变化。
  • @Venky:我只是想改变drawable并删除这条黑线,其他的东西需要保持原样。所以如果这只是使用默认的TabHost来实现,我不想尝试自定义标签。你不知道有什么其他方法可以删除它吗??

标签: android android-tabhost


【解决方案1】:

我没有找到让它在 android 2.1 中工作的方法。所以最后我将项目转换为 android 2.2,现在摆脱了那个小黑线:

  tabHost.getTabWidget().setStripEnabled(false);

【讨论】:

    【解决方案2】:
    How to remove black line from tabbar in Android?
    

    问题在于您的 View with Background 属性。

    如果您为 View 提供背景,它将在您的布局中显示为水平线。

    所以删除你的背景属性android:background="#9deafa"

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

    【讨论】:

    • 但我没有删除该行的代码。View 现在可能是个问题吗?请提供该代码。我将使用已删除的视图进行检查。
    • @Hiral 只需从您的 xml 中删除 android:background="#9deafa"。
    【解决方案3】:

    它非常适合我:

    为您的活动应用自定义主题,并取消 android:windowContentOverlay 属性。

    themes.xml中定义一个主题:

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

    将主题应用于您的应用程序或 AndroidManifest.xml 中的活动:

    &lt;application android:theme="@style/YourTheme" ... &gt;

    【讨论】:

      【解决方案4】:

      添加这一行 安卓:tabStripEnabled="假" 在 XML 文件中的 TabWidget 标记中。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-02-22
        • 2020-12-04
        • 1970-01-01
        • 2016-12-22
        • 2017-11-19
        • 1970-01-01
        相关资源
        最近更新 更多