0

here is my code to create action bar

// enabling action bar app icon and behaving it as toggle button
    ActionBar actionBar=getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setBackgroundDrawable(new ColorDrawable(color.white));
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    for (int i=1; i <= 3; i++) {
        Tab tab = actionBar.newTab();
        tab.setText("Tab " + i);
        tab.setTabListener(this);
        actionBar.addTab(tab);

    }

here is output of my code enter image description here

But I wont display like this enter image description here

Please anyone help me for this Thanks in advance...

SAndroidD
  • 1,745
  • 20
  • 33

1 Answers1

1

Quoting docs

The tabs provided by the ActionBar are ideal because they adapt to different screen sizes. For example, when the screen is wide enough the tabs appear in the action bar alongside the action buttons (such as when on a tablet, shown in figure 7), while when on a narrow screen they appear in a separate bar (known as the "stacked action bar", shown in figure 8). In some cases, the Android system will instead show your tab items as a drop-down list to ensure the best fit in the action bar.

Figure 7 and 8 can be viewed @ http://developer.android.com/guide/topics/ui/actionbar.html

If you are looking for slidingtab's

https://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabLayout.html

Similar to

Android - Google Play like tabs

Community
  • 1
  • 1
Raghunandan
  • 132,755
  • 26
  • 225
  • 256