I am using PagerSlidingTabStrip it's working fine in portrait mode but when I change it to landscape mode then they tabs don't cover all the screen real estate and stays left aligned.

How to make them evenly spaced?

How to fix it?

有帮助吗?

解决方案

Just go the library class i.e. PagerSlidingTabStrip and change this line

private boolean shouldExpand = false; 

to

private boolean shouldExpand = true;

Hope this helps.!

其他提示

<com.astuetz.PagerSlidingTabStrip
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="36dp"
        android:background="@drawable/background_tabs"
        android:fillViewport="false"
        viewpager_:pstsIndicatorHeight="3dp"
        viewpager_:pstsShouldExpand="true" /> <---just make it true

Try setting the width of your PagerSlidingTabStrip as match_parent. :)

<com.example.PagerSlidingTabStrip
    android:id="@+id/tabs"
    **android:layout_width="match_parent"**
    android:layout_height="48dip"
    android:background="@drawable/background_tabs" />
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top