8

I'm developing a screen with three fragments tabs. The tabs title only have their first letter in uppercase:

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

But when I run the app, the titles are displayed all in uppercase.

How can I make the tabs display the words properly?

Tabs setup 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 display 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>

RominaV
  • 3,335
  • 1
  • 29
  • 59
user3825086
  • 111
  • 1
  • 2
  • 12

2 Answers2

2

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

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

Chetan Gaikwad
  • 1,268
  • 1
  • 13
  • 26
  • i m Using Actionbar sherlock Theme Can U Tell mE How to Set false – user3825086 Dec 17 '14 at 10:29
  • First Later Should BE In Caps ..not All in small letter – user3825086 Dec 17 '14 at 11:26
  • [http://stackoverflow.com/questions/23250105/how-to-change-actionbar-tab-textstyle](http://stackoverflow.com/questions/23250105/how-to-change-actionbar-tab-textstyle) in this i Followed The Answer ..But My Tab Name All In Small Letter – user3825086 Dec 17 '14 at 12:20
1

Use below code:

<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" />
subrahmanyam boyapati
  • 2,836
  • 1
  • 18
  • 28