Search code examples
androidandroid-tabhost

Having lower case title in TabHost


I've implemented Tabhost from following code, the title seems to be in uppercase by default. How to place a lowercase title in the Tabhost ?

Here's my code for Tabhost implementation.

TabHost tabHost =getTabHost() ;

      // Tab for public
       TabHost.TabSpec publiComp = tabHost.newTabSpec("Public");
       publiComp.setIndicator("Public");
       Intent publicIntent = new Intent(this, CompliancePublic.class);
       publiComp.setContent(publicIntent);

       // Tab for private
       TabHost.TabSpec privateComp = tabHost.newTabSpec("Private");
       privateComp.setIndicator("Private");
       Intent privateIntent = new Intent(this, CompliancePrivate.class);
       privateComp.setContent(privateIntent);

       tabHost.addTab(publiComp);
       tabHost.addTab(privateComp);

Solution

  • try this

    mTabHost = (FragmentTabHost) view.findViewById(android.R.id.tabhost);
    
    mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.realtabcontent);
    
    View tabIndicatorToday = LayoutInflater.from(getActivity()).inflate(R.layout.tab_indicator, mTabHost.getTabWidget(), false);
            ((TextView) tabIndicatorToday.findViewById(R.id.tv_tab_txt)).setText(getResources().getString(R.string.text));
    
    mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.text)).setIndicator(tabIndicatorToday), Fragment.class, null);
    

    and give your own style to your TextView