Check Mobile App
Read now
Start a Project

Good way to use Locale and make viewpager swipe direction to RTL

Save

There is an issue in view pager while using the RTL.

According to the right-to-left UI paradigm (RTL) a swipe from left to right should scroll page N to page N+1. Currently ViewPager keeps the common LTR swiping direction (a swipe from right to left scrolls page N to page N+1) even if the current locale is an RTL one (Arabic, Hebrew).

So in this blog, we have shown you how to make your Viewpager swipe direction from right to left when your current local is RTL.

So It is the very simple technique to change the swipe direction of the Viewpager.

XML Layouts

You’ll need to make the following changes in all your Layouts

I would recommend you check your app once after applying this change as you might not want all your Layouts/Views to be RTL. If you want to force any layout to LTR then just add android:layoutDirection=”locale” to that view.

Like:

 

So It will work perfectly in ViewPager. No need to rotate the directions.

Old:

There are two simple step which has to follow you,

Step 1. Change the rotation of the View pager,

Step 2. Then again change the direction of the fragment container which is the child of Viewpager,

Note: In my case, I have used Recyclerview as the child of the view pager.

Some Talks by https://code.google.com/p/android/issues

Cheers Coders.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


3 comments

  • Badr At
    thaaanks a lot, it saved my life
  • asad
    Love u bro.
  • Jay
    it is creating scroll/swipe issues in only devices with API 28 otherwise it is working perfectly fine.
  • css.php

    When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

    Michael Urresta

    Michael Urresta

    Talk to Sales

    Global

    Live Chat
    Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home