How to set tab name to lowercase LIke I Want In android

I am developing a screen with three tabs of fragments. The tab header has only the first letter in upper case:

 private String[] tabs = { "About Me", "Education","ProfileEdit"};

But when I run the application, the headers are displayed in uppercase.

How to make tabs display words correctly?

Tab Settings Code:

  private String[] tabs = { "About Me", "Education","ProfileEdit"};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.editprofile);
    user=(UserModel)getIntent().getSerializableExtra("USER");
    // Initilization
    viewPager = (ViewPager) findViewById(R.id.pager);
    actionBar = getActionBar();
    mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

    viewPager.setAdapter(mAdapter);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);        

    // Adding Tabs
    for (String tab_name : tabs) {
        actionBar.addTab(actionBar.newTab().setText(tab_name.toLowerCase())
                .setTabListener(this));
    }

    /**
     * on swiping the viewpager make respective tab selected
     * */
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            // on changing the page
            // make respected tab selected
            actionBar.setSelectedNavigationItem(position);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
}

@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}

@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
    // on tab selected
    // show respected fragment view
    viewPager.setCurrentItem(tab.getPosition());
}

@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}

UPDATE

I edited the theme with textAllCaps false, but the words are displayed in the same way:

<resources>
<style name="MyTheme" parent="Theme.Sherlock">
    <item name="actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
    <item name="android:actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
</style>
<style name="MyMenuTextAppearance" parent="TextAppearance.Sherlock.Widget.ActionBar.Menu">
    <item name="android:textAllCaps">false</item>
</style>

+4
source share
3 answers

The default theme for tab views in Android 4.0 (Holo theme) has android: textAllCaps set to true. Cm:

http://android-developers.blogspot.in/2011/04/customizing-action-bar.html

+2
source

Tablayout styles.xml

<style name="TabTextAppearance" parent="TextAppearance.Design.Tab">
    <item name="textAllCaps">false</item>
</style>

:

<android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        app:tabTextAppearance="@style/TabTextAppearance"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

. .

+16

Use the code below:

<android.support.design.widget.TabLayout
                    android:id="@+id/tabLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:tabIndicatorColor="@android:color/white"
                    app:tabIndicatorHeight="2dp"
                    app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
                    app:tabSelectedTextColor="@android:color/white"
                    app:tabTextColor="@android:color/white" />
0
source

All Articles