Thanks to @CommonsWare for his help. I just needed to change this line:
tabsContainer = new LinearLayout(context);
to
tabsContainer = new LinearLayout(context);
tabsContainer.setGravity(Gravity.RIGHT);
سؤال
How to align the tabs in the ViewPager to the right instead of the left? I am using android.support.v4.view.ViewPager
if that matters.
I've tried android:layout_gravity="right"
but it doesn't affect the alignment:
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right">
</android.support.v4.view.ViewPager>
المحلول
Thanks to @CommonsWare for his help. I just needed to change this line:
tabsContainer = new LinearLayout(context);
to
tabsContainer = new LinearLayout(context);
tabsContainer.setGravity(Gravity.RIGHT);
نصائح أخرى
Or you just add this line:app:pstsShouldExpand="true"
to be:
<com.example.PagerSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="48dip"
app:pstsShouldExpand="true" />
You should be setting it to
<android.support.v4.view.PagerTitleStrip
...
android:layout_gravity="right"
/>
Use this code :
tabsContainer.setLayoutDirection(LAYOUT_DIRECTION_RTL);
tabsContainer.setGravity(Gravity.RIGHT);