TabLayout on landscape not showing gravity_fill and mode_fixed
<p>I'm using <code>TabLayout</code> and <code>ViewPager</code> together to do a tabbed viewpager.</p>

<p>I've got a weird behavior in landscape where <code>TabLayout.GRAVITY_FILL</code> and <code>TabLayout.MODE_FIXED</code> don't seem to work, regardless of being set in java or xml (they do just fine for portrait).</p>

<p>However! When I do THREE tabs, everything is a-ok!</p>

<p><strong>The problem is with TWO tabs - in landscape.</strong></p>

<p>My Activity:</p>

<pre><code>public class TabbedViewPager extends AppCompatActivity {
    private ViewPager viewPager;

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

        initTabLayout1();
    }

    public void initTabLayout1() {
        TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);

        TabLayout.Tab tab1 = tabLayout.newTab();
        tab1.setText("Tab 1");
        tabLayout.addTab(tab1);
        TabLayout.Tab tab2 = tabLayout.newTab();
        tab2.setText("Tab 2");
        tabLayout.addTab(tab2);
        //TabLayout.Tab tab3 = tabLayout.newTab();
        //tab3.setText("Tab 3");
        //tabLayout.addTab(tab3);
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);

        viewPager = (ViewPager) findViewById(R.id.view_pager);
        final TabbedPagerAdapter adapter = new TabbedPagerAdapter(getSupportFragmentManager(),
                tabLayout.getTabCount());
        viewPager.setAdapter(adapter);

        viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
        tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                viewPager.setCurrentItem(tab.getPosition());
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {}

            @Override
            public void onTabReselected(TabLayout.Tab tab) {}
        });
    }
}
</code></pre>

<p>My Fragment, same for both One and Two, (with a blank/bg-colored xml):</p>

<pre><code>public class FragmentOne extends Fragment {
    public FragmentOne() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_one, container, false);
        return view;
    }
}
</code></pre>

<p>My Adapter:</p>

<pre><code>public class TabbedPagerAdapter extends FragmentStatePagerAdapter {
    private int mNumOfTabs;

    public TabbedPagerAdapter(FragmentManager fm, int NumOfTabs) {
        super(fm);
        this.mNumOfTabs = NumOfTabs;
    }

    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                FragmentOne tab1 = new FragmentOne();
                return tab1;
            case 1:
                FragmentTwo tab2 = new FragmentTwo();
                return tab2;
            case 2:
                FragmentOne tab3 = new FragmentOne();
                return tab3;
            default:
                return null;
        }
    }

    @Override
    public int getCount() {
        return mNumOfTabs;
    }
}
</code></pre>

<p>My Activity XML:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_tabbed_view_pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.samp.ling.sampleapp.examples.TabbedViewPager"&gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:orientation="vertical"&gt;

        &lt;android.support.design.widget.TabLayout
            android:id="@+id/tab_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:elevation="6dp"
            android:minHeight="?attr/actionBarSize"
            android:background="@android:color/holo_orange_light"
            app:tabIndicatorColor="@android:color/holo_orange_dark"
            app:tabIndicatorHeight="5dp"/&gt;
        &lt;!--app:tabGravity="fill"--&gt;
        &lt;!--app:tabMode="fixed"--&gt;

        &lt;android.support.v4.view.ViewPager
            android:id="@+id/view_pager"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"/&gt;

    &lt;/LinearLayout&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p><a href="https://i.stack.imgur.com/mOrs3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mOrs3.png" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/JLAMM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JLAMM.png" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/Ev5Dr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Ev5Dr.png" alt="enter image description here"></a></p>

<p>As seen from above, exact same code besides an extra tab, 2-tabs don't adhere to tablayout's fill/fixed in landscape - <strong>why? what's wrong?</strong></p>

<p>Oh, this is with the latest support libraries:
<code>appcompat-v7:25.0.1</code>, <code>support-v4:25.0.1</code>, <code>design:25.0.1</code></p>

<p>Thanks!</p>