Search code examples
androidandroid-tablayout

Tab layout swipe direction


Can I change the swipe direction of Tabs in TabLayout by code?

It works fine when my device's language is English, But when I change it to Arabic, A lot of tabs disappear and the swipe's direction still the same (to The Right ). Note: In Manifest file support RTL option is "true".


Solution

  • The actual problem you facing is the fact, that ViewPager still does not support RTL.

    It's well-known and very old issue - you can find it in Google's issue tracker: ViewPager RTL swipe direction

    So far, I haven't seen any successful examples of RLT's implementation. For, example, there's one from Booking.com, but it doesn't work with TabLayout yet. I'd suggest to dig into it and try to fix the issue there, than start writing it from scratch.

    UPD: I forked Booking's RtlViewPager and fix it for TabLayout's. Feel free to try it!

    enter image description here