15

This question has been asked (for example, here Using ViewPager with Tabs without actionBar), however the answer there doesn't work. There's some links to Swipey but unfortunately the link is broken too.

The example from Android site EffectiveNavigation uses Actionbar to host the tab fragment, so obviously if I set a .NoActionBar theme, then there's no host. Any different way? Thanks.

Update screenshot of what I want to create, at the top, there's no actionbar. enter image description here

Update 2 this is from the google example, there's an actionbar on top (titled "Effective navigation), which I want to get rid of

enter image description here

Community
  • 1
  • 1
EyeQ Tech
  • 7,198
  • 18
  • 72
  • 126

3 Answers3

28

Solution of your problem is already given in http://developer.android.com/

To disableAction-bar Icon and Title, you must do two things:

 setDisplayShowHomeEnabled(false);  // hides action bar icon
 setDisplayShowTitleEnabled(false); // hides action bar title

Follow The Steps given in Using split action bar

Write Following Code in OnCreate()

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.navigation_drawer);

        getActionBar().setDisplayShowHomeEnabled(false);  // hides action bar icon
        getActionBar().setDisplayShowTitleEnabled(false); // hides action bar title
        //rest of your code...
}

enter image description here

After Android updated Actionbar to Toolbar there are many changes in Actionbar Tabs.

Please follow below links to create swipable tabs in Andoid.

Design Structure :

Tabs Design Guidelines

enter image description here

Some of the very useful links are below. Please refer to them.

Download sample zip from below link

http://developer.android.com/samples/SlidingTabsBasic/index.html

Or Refer these links

http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html

http://www.exoguru.com/android/material-design/navigation/android-sliding-tabs-with-material-design.html

http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/

https://guides.codepath.com/android/Google-Play-Style-Tabs-using-TabLayout

This may help you...

Pragnesh Ghoda シ
  • 8,318
  • 3
  • 25
  • 40
  • I am trying to use that but it gives me an error... any ideas? – Vlad Sep 18 '15 at 21:12
  • @Vlad : Hi Vlad, this is an old answer. Android got updated in way to far from this so you have to use new methods and fundamentals to implement this type of view. Actionbar got updated to Toolbar. Please follow below link to implement this type of behavior. http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html – Pragnesh Ghoda シ Sep 19 '15 at 04:25
  • I just want to say well done for a pretty exemplary answer – Nick Cardoso Oct 29 '16 at 18:17
9

You can:

  • Use a ViewPager with a PagerTabStrip

  • Use a ViewPager with the TabPageIndicator class from the ViewPagerIndicator library

  • Use a ViewPager with other third-party tab indicators (e.g., in the "View Pagers" category at the Android Arsenal)

  • Use a ViewPager and design your own tabbed indicator

  • Use a FragmentTabHost and skip the swiping part

smac89
  • 39,374
  • 15
  • 132
  • 179
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

Along with

getActionBar().setDisplayShowHomeEnabled(false);
getActionBar().setDisplayShowTitleEnabled(false);

Use this as well

getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
Ali Akram
  • 199
  • 4
  • 12