TabLayout 未扩展到整个屏幕宽度

TabLayout not expanding over whole screen width

我还想填充 space TabLayout 的左侧和右侧,以便它填满整个屏幕。但是我就是无法让它工作。这是我的 Layout.xml.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="cytek2806northman.tabtestproject.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_height = "wrap_content"
        android:layout_width = "match_parent"
        >

        <android.support.design.widget.TabLayout
            android:layout_height = "wrap_content"
            android:layout_width = "match_parent"
            android:id="@+id/tabLayout"
            app:tabMode="scrollable"
            app:tabGravity="fill"
            >
        </android.support.design.widget.TabLayout>


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

        <android.support.v4.view.ViewPager
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/viewPager">
        </android.support.v4.view.ViewPager>


</RelativeLayout>

既然我看不到你在相对布局中的边距值是多少,那么一定是这些属性导致了空白。删除它们,它应该可以工作,因为其他任何东西看起来都是正确的。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="cytek2806northman.tabtestproject.MainActivity">

解决方案正在删除

android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"