androidandroid-layoutxamarinxamarin.androidandroid-tabs

Tabs Swipe direction in Right to Left Android app


I have an Android app that has tabs. I want the app to be Right to Left.
I put android:supportsRtl="true" in the manifest file, and changed some of the elements to be android:layoutDirection="rtl".

It changes everything to right to left, which is what I want, except that it reversed the swiping direction in the tabs- when you swipe to the left, it moves to the left tab, instead of the opposite from the swipe. I want to change it to make it a regular swipe.

This is my code:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right"
android:fitsSystemWindows="true"
android:id="@+id/drawer_layout">
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layoutDirection="rtl">
    <include
        android:id="@+id/toolbar"
        android:gravity="right"
        layout="@layout/toolbar" />
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/main_layout"
        android:layout_below="@id/toolbar">
        <com.refractored.PagerSlidingTabStrip
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:textColor="#ecf0f1"
            app:pstsShouldExpand="true"/>

        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            tools:context=".MainActivity" />
    </LinearLayout>
</RelativeLayout>
<android.support.design.widget.NavigationView
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:id="@+id/nav_view"
    android:layoutDirection="rtl"
    app:headerLayout="@layout/header"
    app:menu="@menu/nav_menu" />
</android.support.v4.widget.DrawerLayout>

Hope you can help me.

Thanks!


Solution

  • I added:

    android:layoutDirection="ltr" to TabLayout.

    NOT

    android:layoutDirection="rtl"

    and it worked just fine