2

As shown in the picture

Is it possible to create Tabs inside ActionBar?

I have managed only to create TabHost but it goes under the ActionBar and not inside it (I think that is obvious that tabs are inside cause there is a perfect flow from ActionBar title to tabs).

Rami
  • 7,879
  • 12
  • 36
  • 66
Captain Lemon
  • 37
  • 2
  • 8

2 Answers2

4

As @Rami said:

Those tabs in your picture are not in the ActionBar, they are under the ActionBar

And you can use that with TabLayout (from support library) or the other libraries.which the TabLayoutis the best option to use.

Here is a good tutorial: https://guides.codepath.com/android/google-play-style-tabs-using-tablayout

And check this link too: How to implement android TabLayout design support libarary with Swipe views

Example:

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:layout_scrollFlags="scroll|enterAlways" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</android.support.design.widget.AppBarLayout>

Take a look: Tabs in TabLayout not filling up entire ActionBar

Community
  • 1
  • 1
ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
0

According to Picture the Tab is not inside the action bar but the Tabs color and action bar color is same so that's why it look like

Muhammad Younas
  • 1,543
  • 1
  • 22
  • 32