Android 删除标签栏中的底线边框?(并更改所选颜色)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3543478/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 10:41:48  来源:igfitidea点击:

Remove the bottom line border in tab bar? (And change selected color)

androiduser-interface

提问by droidgren

Is it possible to remove the bottom line showed in the tab bar? It is grey when not selected.

是否可以删除标签栏中显示的底线?未选择时为灰色。

And is it possible to change the yellowish color to something else?

是否可以将黄色更改为其他颜色?

alt text

替代文字

layout xml: http://pastebin.com/M2KqtH1r

布局xml:http: //pastebin.com/M2KqtH1r

回答by Jashan PJ

just do this in your tabWidget in your xml file.

只需在您的 xml 文件中的 tabWidget 中执行此操作。

android:tabStripEnabled="false"

hope you get it. ;)

希望你能明白。;)

回答by Siklab.ph

In AndroidManifest.xml:

在 AndroidManifest.xml 中:

 <activity android:name=".ActivityName" android:theme="@style/tabTheme"/> 

In values/styles.xml:

在 values/styles.xml 中:

 <style name="tabTheme" parent="android:style/Theme"> 
      <item name="android:tabWidgetStyle">@style/Widget.TabWidget</item>
 </style> 

 <style name="Widget.TabWidget" parent="android:Theme"> 
      <item name="android:tabStripEnabled">false</item>
 </style>  

回答by Mightian

android:tabStripEnabled="false" didnt work for me
By doing the following i was able to get it working

android:tabStripEnabled="false" 对我不起作用
通过执行以下操作,我能够使其正常工作

<android.support.design.widget.TabLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabIndicatorColor="@android:color/transparent"
        app:tabIndicatorHeight="0dp" />

These 2 are the main things

这2点是主要的

 app:tabIndicatorColor="@android:color/transparent"
            app:tabIndicatorHeight="0dp"

回答by xackobo

Finally I solved it by:

最后我通过以下方式解决了它:

android:alpha="0"

Here the full code:

这里是完整的代码:

<?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">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center_horizontal">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:tabStripEnabled="false"
            android:alpha="0"
            style="@style/TabStyle" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
</TabHost>

回答by Praveen

you have customize your tab indicator. that is to overriding your tabwidget style. I had this problem already. check these two posts. post1and post2. Hope it helps.

您已经自定义了选项卡指示器。那就是覆盖您的 tabwidget 样式。我已经有这个问题了。检查这两个帖子。post1post2。希望能帮助到你。

回答by Sephy

It seems that the way of doing that is to nest the tabwidget in a LinerLayout... Look here.

似乎这样做的方法是将 tabwidget 嵌套在 LinerLayout 中......看这里

回答by subodh meshram

For disabling that line below use tab:

要禁用下面的那一行,请使用选项卡:

app:tabIndicator="@null"