如何从FragmentTabhost中删除选定的选项卡指示器? [英] How to remove the selected tab indicator from the FragmentTabhost?

查看:131
本文介绍了如何从FragmentTabhost中删除选定的选项卡指示器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了几个链接,以删除FragmentTabHost中的所选标签,但对我不起作用.
第一个链接
第二个链接

I have tried several links for remove the selected tab in FragmentTabHost but does not work for me .
First link
Second link

我也在Xml中也尝试过此操作,但是它不起作用

I have tried this also in my Xml but it is not working

android:tabStripEnabled="false"

这是我的fragmenttabhost的布局.

And it is my layout for the 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)

Moto E设备


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(您的标签位置").setBackground(null);

fragmentTabHost.getTabWidget().getChildAt("Your tab position").setBackground(null);

仅需生孩子并将其背景设置为空,就可以了

这篇关于如何从FragmentTabhost中删除选定的选项卡指示器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆