androidandroid-fragmentsandroid-scrollable-tabs

Is there any way to have embedded scrollable tabs?


I have a layout in my head that should look like that: https://i.sstatic.net/1UbUN.png

Only part that will be dynamic is the blue one. I don't know the number of tabs that will be created before I load the activity, hence the number is acquired from server (could be either 5 or 24 for all I know).

The bottom buttons should not move when I swipe and the blue area changed.

Currently I have this implemented w/o tabs list using embedded fragment in my activity and gesture listener. There's no good looking transaction animation between fragments.


Solution

  • @Nick Pakhomov: You can use PagerTabStrip

    PagerTabStrip

    is intended to be used as a child view of a ViewPager widget in your XML layout. PagerTabStrip is most often used with fragment, which is a convenient way to supply and manage the Lifecycle of each fragment.

    So here’s how a ViewPager with a PagerTabStrip in it would look like in the layout file:

      <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
     
        <android.support.v4.view.PagerTabStrip
            android:id="@+id/pager_tab_strip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:background="#33b5e5"
            android:textColor="#fff"
             />
     
     
    </android.support.v4.view.ViewPager>
    

    Please check this PagerSlidingTabStrip demo . I hope it will helps you .