简体   繁体   English

如何从FragmentTabhost中删除选定的选项卡指示器?

[英]How to remove the selected tab indicator from the FragmentTabhost?

I have tried several links for remove the selected tab in FragmentTabHost but does not work for me . 我已经尝试了几个链接来删除FragmentTabHost中的选定选项卡,但对我来说不起作用。
First link 第一个链接
Second link 第二个环节

I have tried this also in my Xml but it is not working 我也在我的Xml中试过这个,但是它没有用

android:tabStripEnabled="false"

And it is my layout for the fragmenttabhost. 这是我对fragmenttabhost的布局。

<FrameLayout

    android:id="@+id/realtabcontent"
    android:layout_width="match_parent"
    android:layout_weight="1"
    android:layout_height="0dp"
     />
    <android.support.v4.app.FragmentTabHost
      android:id="@android:id/tabhost"
      android:layout_width="match_parent"
      android:layout_alignParentBottom="true"
      android:background="@drawable/top_bg"
      app:tabIndicatorColor="#000"
      android:tabStripEnabled="false"
      app:tabIndicatorHeight="0dp"
      android:layout_height="60dp"
      >

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0" />

    <LinearLayout
        android:id="@+id/tab_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:showDividers="none"
        android:orientation="horizontal"
        android:weightSum="5" >

        <ImageView
            android:id="@+id/genralTabBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:padding="15dp"
            android:background="@drawable/button_1_off" />

        <ImageView
            android:id="@+id/treandingTabBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:padding="12dp"
            android:background="@drawable/button_2_off" />

        <ImageView
            android:id="@+id/profileTabBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:padding="12dp"
            android:background="@drawable/button_3_off" />

</android.support.v4.app.FragmentTabHost>

And in my devices selected tab look like (Plz check images) 在我的设备选择标签看起来像(Plz检查图像)

Moto E device Moto E设备

Moto E设备

HTC device HTC设备 HTC设备

Sorry For Late Reply I am also getting this issue and I tried many things on it and finally I get success. 对不起迟到的回复我也遇到了这个问题,我尝试了很多东西,最后我获得了成功。

Try This Below code. 试试下面的代码。

 fragmentTabHost.addTab(fragmentTabHost.newTabSpec("tab1").setIndicator("", getResources().getDrawable(R.drawable.tab1)),
            HomeFragment.class, null);

    fragmentTabHost.getTabWidget().getChildAt(0).setBackground(null);//set child background as null 
    fragmentTabHost.addTab(fragmentTabHost.newTabSpec("tab2").setIndicator("", getResources().getDrawable(R.drawable.tab2)),
            CartFragment.class, null);
    fragmentTabHost.getTabWidget().getChildAt(1).setBackground(null););//set child background as null 

    fragmentTabHost.addTab(fragmentTabHost.newTabSpec("tab3").setIndicator("", getResources().getDrawable(R.drawable.tab3)),
            MoreStuffFragment.class, null);
    fragmentTabHost.getTabWidget().getChildAt(2).setBackground(null); );//set child background as null 

fragmentTabHost.getTabWidget().getChildAt("Your tab position").setBackground(null); fragmentTabHost.getTabWidget()。getChildAt(“你的标签位置”)。setBackground(null);

Simply you have to get child and set it's background as null and you have done 简单地说,你必须得到孩子并将它的背景设置为null并且你已经完成了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM