androidandroid-tabsandroid-7.0-nougat

Extra white space on SlidingTabLayout bar in Android 7.0 N?


Just upgraded to Android 7.0 and all my SlidingTabLayout bars now have extra white space on the bottom. Not sure if this is intended by the Android team or not, but is there anyway of getting rid of the new white space?

Extra White Space on SlidingTabLayout bar

I am using code provided by Android which can be found here:

Sliding Tab Layout: https://developer.android.com/samples/BasicTransition/src/com.example.android.common/view/SlidingTabLayout.html

Sliding Tab Strip: https://developer.android.com/samples/BasicTransition/src/com.example.android.common/view/SlidingTabStrip.html

Here is a snippet of my layout code:

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/tool_bar"
        android:layout_height="56dp"
        android:layout_width="match_parent"
        android:background="@drawable/toolbar_gradient"
        app:layout_scrollFlags="scroll|enterAlways"
        android:theme="@style/Base.ThemeOverlay.AppCompat.Dark" />

    <com.airsenze.wineinsider.controllers.SlidingTabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"/>

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

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:layout_width="match_parent">
</android.support.v4.view.ViewPager>

Thanks! Let me know if you need anymore information.


Solution

  • Thanks to MihaiW, This happens when distributeEvenly is true. Just replace this line:

    lp.width = 0;
    

    With:

    lp.width = ViewGroup.LayoutParams.MATCH_PARENT
    

    in the populateTabStrip() method in the SlidingTabLayout.java class and your problem will be solved.