Java app:pstshouldexpand=";“真的”;撞坏我的ap

Java app:pstshouldexpand=";“真的”;撞坏我的ap,java,android,xml,android-studio,Java,Android,Xml,Android Studio,大家好,我有一个问题:pstshouldexpand=“true”在 com.astuetz.PagerSlidingTabStrip 当我从布局中删除com.astuetz.pagerslidingAbstrip时!它工作得很好,但当我使用(app:pstshouldexpand=“true”)时,我的应用程序会崩溃 这是我的布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http:

大家好,我有一个问题:pstshouldexpand=“true”在

com.astuetz.PagerSlidingTabStrip

当我从布局中删除com.astuetz.pagerslidingAbstrip时!它工作得很好,但当我使用(app:pstshouldexpand=“true”)时,我的应用程序会崩溃

这是我的布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          android:orientation="vertical">


<android.support.v7.widget.Toolbar
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/colorPrimary">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/img_login"
            android:layout_width="40dp"


            android:layout_height="45dp"
            android:layout_gravity="right"
            android:layout_marginRight="5dp"
            android:layout_marginTop="4dp"
            android:onClick="on_img_login_click"
            android:src="@drawable/ic_account_circle_black_24dp"/>

    </LinearLayout>


</android.support.v7.widget.Toolbar>


<com.astuetz.PagerSlidingTabStrip
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="48dip"
   app:pstsShouldExpand="true"

    />

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

    >



</android.support.v4.view.ViewPager>



</LinearLayout>

1)将活动内容视图设置为空linearlayout XMLfile

 setContentView(R.layout.pagerslidingtabstrip_viewpager);
2) 找到布局并将其保存在变量中

 LinearLayout mainLayout = (LinearLayout) findViewById(R.id.main_layout_view);
3) 从单独的XLM文件中为viewpager充气,而不是仅包含viewpager元素

   mLayoutInflater = getLayoutInflater();
    mInflatedViewPagerLayout =  mLayoutInflater.inflate(R.layout.separate_viewpager,null);
    mViewPager = mInflatedViewPagerLayout.findViewById(R.id.viewpager);
4) 从代码中创建和配置滑动选项卡

mTabStripLayout = new PagerSlidingTabStrip(this);
mTabStripLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 140));
mTabStripLayout.setShouldExpand(true);
mTabStripLayout.setAllCaps(true);
mTabStripLayout.setTextSize(60);
mTabStripLayout.setTextColor(Color.BLACK);
mTabStripLayout.setDividerColor(Color.BLUE);
mTabStripLayout.setDividerPadding(30);
mTabStripLayout.setIndicatorColor(Color.RED);
mTabStripLayout.setIndicatorHeight(15);
mTabStripLayout.setUnderlineColor(Color.BLUE);
4) 按相同顺序添加滑动选项卡和viewpager以线性布局

  mainLayout.addView(mTabStripLayout);
    mainLayout.addView(mViewPager);
5) 像往常一样完成其余的设置,如创建适配器、将适配器分配给

viewpager, and assigning viewpager to sliding tabs

    mPagerAdapter = new SampleFragmentPagerAdapter(getSupportFragmentManager());
    mViewPager.setAdapter(mPagerAdapter);
    mTabStripLayout.setViewPager(mViewPager);
或者在
xml

<com.astuetz.PagerSlidingTabStrip
    android:id="@+id/tabs"
    app:pstsShouldExpand="true"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:textSize="14sp"
    android:textColor="#000000"
    app:pstsDividerColor="@color/green"
    app:pstsIndicatorColor="@color/red"
    app:pstsUnderlineColor="@color/blue"
    app:pstsTabPaddingLeftRight="14dp">
</com.astuetz.PagerSlidingTabStrip>