user4386126
user4386126

Reputation: 1245

Make PagerTabStrip with two tabs equally fit in screen

I am using ViewPager with PagerTabStrip:

    <android.support.v4.view.ViewPager
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v4.view.PagerTabStrip
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top"/>

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

And I would like to accomplish my tabs to look like this as Google recommends:

enter image description here

I have two tabs and I would like for each of them to be fixed and take 50% of the screen. I was looking through the options in XML and programmatically and can't find anything useful.

How can I accomplish that? Thank you.

Upvotes: 3

Views: 1826

Answers (2)

qianlv
qianlv

Reputation: 550

You should use android.support.design.widget.TabLayout instead of PagerTabStrip.

Upvotes: 2

dooplaye
dooplaye

Reputation: 1029

I'm not sure about android.support.v4.view.PagerTabStrip. But you can use alternative library for getting this effect, i use it in my one project and it works well. After you add the lib to your project, set pstsShouldExpand to true

Upvotes: 4

Related Questions