Use Tab with new ToolBar (AppCompat v7-21)
With the API 21 the method setNavigationMode(ActionBar.NAVIGATION_MODE_TABS) is deprecated. UPDATE 01/08/2019 (Material Components Library) Add the dependency to your build.gradle: dependencies { implementation ‘com.google.android.material:material:1.1.0’ } Then you can use the new TabLayout. <androidx.constraintlayout.widget.ConstraintLayout> <com.google.android.material.appbar.AppBarLayout …> <androidx.appcompat.widget.Toolbar …/> <com.google.android.material.tabs.TabLayout … /> </com.google.android.material.appbar.AppBarLayout> <androidx.viewpager.widget.ViewPager android:id=”@+id/viewpager” app:layout_behavior=”@string/appbar_scrolling_view_behavior” /> </androidx.constraintlayout.widget.ConstraintLayout> The code is simple: TabLayout tabs = (TabLayout) findViewById(R.id.tabs); … Read more