How do I remove the selected tab indicator from the TabWidget?

后端 未结 17 1279
猫巷女王i
猫巷女王i 2020-12-09 02:19

Here\'s what I\'d like to remove :

\"enter

How do I replace the indicator show

17条回答
  •  爱一瞬间的悲伤
    2020-12-09 03:00

    If android:tabStripEnabled="false" did not work then I also assume calling setStripEnabled(boolean stripEnabled) will have no effect as well. If all of this is true then your problem is probably not in TabWidget.

    I would suggest looking at your tab indicator. Try these modifications. This code is taken from a fragment that has tabs.

    Here is the code that creates the tab indicator view.

        View indicator = LayoutInflater.from(getActivity()).inflate(R.layout.tab,
    (ViewGroup) mRoot.findViewById(android.R.id.tabs), false);
    
            TabSpec tabSpec = mTabHost.newTabSpec(tag);
            tabSpec.setIndicator(indicator);
            tabSpec.setContent(tabContentId);
    

    Your tab indicator view would probably like similar to this.

    
    
    
        
    
    
    

    Now the important part here is the android:background="@drawable/tabselector" in the LinearLayout. Mine looks like this.

    
    
        
        
        
        
        
        
        
    
    

    This tabselector.xml is where you will swap @drawable/tab_pressed_light with your @drawable/tab_button_active and @drawable/tab_unselected_light with @drawable/tab_button_inactive

    Be sure to check that all of your drawables that go into your tabselector.xml do not have the blue strips along the bottom. As I look at your image I can see little 5px gaps along that strip this is what gave me the idea that the strip was not from your TabWidget. Hope this helps.

提交回复
热议问题