1

How do I set it so that tabs start from the right side of the layout?

Like this layout:

enter image description here

I've tried using

app:tabMode="scrollable"
app:tabGravity="center"

but that just centers it, not starting it from the end.

 app:tabGravity="fill"

Causes it to go to the left side, but I want to to go to the right.

Here's my tablayout

<com.google.android.material.tabs.TabLayout
        android:id="@+id/activitypayment_tablayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabIndicator="@null"
        app:tabRippleColor="@null"
        app:tabTextAppearance="@style/PaymentTabLayoutStyle"
        app:tabTextColor="@color/dividerColor"
        app:tabSelectedTextColor="@color/colorBlackFont"
        app:tabMode="scrollable"
        app:tabGravity="center"
        android:overScrollMode="never"
        >

        <com.google.android.material.tabs.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Test1" />

        <com.google.android.material.tabs.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Test2" />

        <com.google.android.material.tabs.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Other" />
    </com.google.android.material.tabs.TabLayout>
DIRTY DAVE
  • 2,523
  • 2
  • 20
  • 83

2 Answers2

0

Add android:layoutDirection="ltr" to your TabLayout and add android:supportsRtl="true" to the android manifest file

0

There is an Easy way what you can try in your Main:

viewPager.setCurrentItem(2);

and set whatever tab you want to be your default;

sina akbari
  • 618
  • 6
  • 7