Android一个标签TabLayout,全宽不起作用

我正在尝试在TabLayout中添加一个带有全宽指示符的选项卡.但是使用谷歌TabLayout我得到了这个结果

之后我确实使用了与https://github.com/astuetz/PagerSlidingTabStrip相同的代码
我得到了正确的结果

以前有人遇到过同样的问题吗?以及如何解决这个问题?

我确实使用了简单的代码只是活动保持

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

        <android.support.design.widget.TabLayout
            android:id="@+id/swipeTabLayout"
            android:layout_width="match_parent"
            app:tabMaxWidth="0dp"
            android:layout_height="30dp"
            app:tabIndicatorHeight="4dp"
            />
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/swipePager"
        android:background="@android:color/transparent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

and the adapter

public class StreamNavigationPagerAdapter extends FragmentStatePagerAdapter {

    private Context mContext;

    public StreamNavigationPagerAdapter(FragmentManager fm,Context con) {
        super(fm);
        mContext = con;
    }


    @Override
    public Fragment getItem(int position) {
        return getNewsFragment();
    }

    private Fragment getNewsFragment() {
        Fragment fragment = new StreamNewsFragment();
        return fragment;
    }

    @Override
    public int getCount() {
            return 1;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return "NEWS";
    }

}

the activity contain just

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            ButterKnife.inject(this);

            swipePager.setAdapter(new StreamNavigationPagerAdapter(getSupportFragmentManager(),this));
            swipeTabLayout.setupWithViewPager(swipePager);
    //        swipeTabLayout.setViewPager(swipePager);
        }

解决方法

我遇到了完全相同的问题,并设法通过将tabMaxWidth属性设置为高值而不是(例如500dp)而不是0dp来解决它,如某些答案中所建议的那样.
<android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMaxWidth="500dp" />

相关文章

Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...