title: Android - make selected tab bold
body: <p>I have ActionBar with NAVIGATION_MODE_TABS and some amount of actual tabs in my application. The task is quite simple: make selected tab title bold (and returning to normal when tab loses selection). But it became a big headache to achieve such a task. Tab object has no methods for accessing underlying TextView. So I've used custom view for tab title, but then this view is positioned wrong:</p>
  
  <p><img src="https://i.stack.imgur.com/jbJUK.png" alt="titles are sticked to the top"></p>
  
  <p>Please help and tell me:</p>
  
  <ul>
  <li>if there's a way to manipulate tab text directly, or</li>
  <li>how can I achieve default positioning for custom TextView?</li>
  </ul>
  
  <p>The code I'm using:</p>
  
  <p>in Activity -></p>
  
  <pre><code>    final ActionBar actionBar = getSupportActionBar();
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
      ActionBar.TabListener tabListener = new ActionBar.TabListener() {
          public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
              mViewPager.setCurrentItem(tab.getPosition());
              TextView textView = (TextView) tab.getCustomView();
              textView.setTypeface(null, Typeface.BOLD);
          }
          public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
              TextView textView = (TextView) tab.getCustomView();
              textView.setTypeface(null, Typeface.NORMAL);
          }
          public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
              // probably ignore this event
          }
      };
  
      for (int i = 0; i &lt; 3; i++) {
          TextView textView = (TextView)
                  getLayoutInflater().inflate(R.layout.tab_title, null);
          textView.setText("Tab " + i);
          actionBar.addTab(actionBar.newTab()
                  .setCustomView(textView)
                  .setTabListener(tabListener));
      }
  </code></pre>
  
  <p>in layout.tab_title -></p>
  
  <pre><code>&lt;TextView xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_gravity="center"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" /&gt;
  </code></pre>