title: how to add support RtL into viewPager Kotlin?
body: <p>I want to add or apply :</p>
  <pre><code>viewPager?.rotationY = 180F
  </code></pre>
  <p>to my view pager just when app language is setted to fa or ps from en. or prevent applying that when language is en.
  I used <code>viewPager?.rotationY = 180F</code> in whole app but I want it apply just to fa and ps language.
  and used <code>android:rotationY=&quot;180&quot;</code> but it apply to all app languages.</p>
  <p>there are all my related codes in DAshboardActivity.kt as below :</p>
  <pre><code>@file:Suppress(&quot;NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS&quot;, &quot;DEPRECATION&quot;)
  </code></pre>
  <p>package af.azdreams.myconquer</p>
  <pre><code>import af.azdreams.myconquer.databinding.ActivityDashboardBinding
  import af.azdreams.myconquer.fragments.ExploreFragment
  import af.azdreams.myconquer.fragments.FlightsFragment
  import af.azdreams.myconquer.fragments.TravelFragment
  import android.annotation.SuppressLint
  import android.content.Context
  import android.content.DialogInterface
  import android.content.Intent
  import android.content.res.Configuration
  import android.graphics.BitmapFactory
  import android.net.Uri
  import android.os.Bundle
  import android.preference.PreferenceManager
  import android.view.View
  import android.widget.ImageView
  import android.widget.TextView
  import android.widget.Toast
  import androidx.appcompat.app.ActionBarDrawerToggle
  import androidx.appcompat.app.AlertDialog
  import androidx.appcompat.app.AppCompatActivity
  import androidx.appcompat.app.AppCompatDelegate
  import androidx.appcompat.widget.Toolbar
  import androidx.drawerlayout.widget.DrawerLayout
  import androidx.fragment.app.Fragment
  import androidx.fragment.app.FragmentManager
  import androidx.fragment.app.FragmentPagerAdapter
  import androidx.viewpager.widget.ViewPager
  import com.bumptech.glide.Glide
  import com.google.android.material.badge.BadgeDrawable
  import com.google.android.material.navigation.NavigationView
  import com.google.android.material.tabs.TabLayout
  import com.google.firebase.auth.FirebaseAuth
  import com.google.firebase.database.*
  import com.google.firebase.database.ktx.database
  import com.google.firebase.ktx.Firebase
  import com.google.firebase.storage.FirebaseStorage
  import com.google.firebase.storage.StorageReference
  import java.io.File
  import java.util.*
  
  class DashboardActivity : AppCompatActivity() {
  private lateinit var storageReference: StorageReference
  private lateinit var databaseReference: DatabaseReference
  private lateinit var user: User
  private lateinit var uid: String
  private var toolbar: Toolbar? = null
  private var viewPager: ViewPager? = null
  private var tabLayout: TabLayout? = null
  private var exploreFragment: ExploreFragment? = null
  private var flightsFragment: FlightsFragment? = null
  private var travelFragment: TravelFragment? = null
  private lateinit var auth: FirebaseAuth
  private lateinit var binding: ActivityDashboardBinding
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      auth = FirebaseAuth.getInstance()
      uid = auth.currentUser?.uid.toString()
      databaseReference = FirebaseDatabase.getInstance().getReference(&quot;Users&quot;)
      if (uid.isNotEmpty()){
          getUserData()
      }
      loadLocale()
      binding = ActivityDashboardBinding.inflate(layoutInflater)
      setContentView(binding.root)
      onClickListenerSearchUser()
      val scoresRef = Firebase.database.getReference(&quot;Users&quot;)
      scoresRef.keepSynced(true)
      initData()
      checkTheme()
      findViewById&lt;Toolbar&gt;(R.id.toolbar).also { toolbar = it }
      setSupportActionBar(toolbar)
      findViewById&lt;ViewPager&gt;(R.id.viewPager).also { viewPager = it }
      findViewById&lt;TabLayout&gt;(R.id.tabLayout).also { tabLayout = it }
      exploreFragment = ExploreFragment()
      flightsFragment = FlightsFragment()
      travelFragment = TravelFragment()
      with(tabLayout) { this?.setupWithViewPager(viewPager) }
      val viewPagerAdapter = ViewPagerAdapter(supportFragmentManager, 0)
      viewPagerAdapter.addFragment(exploreFragment!!,resources.getString(R.string.home))
      viewPagerAdapter.addFragment(flightsFragment!!,resources.getString(R.string.flights))
      viewPagerAdapter.addFragment(travelFragment!!,resources.getString(R.string.dictionary))
      with(viewPager) {
          this!!.adapter = viewPagerAdapter
      }
  
      val tabLayout = tabLayout
      tabLayout?.getTabAt(0)?.setIcon(R.drawable.icon_home)
      tabLayout?.getTabAt(1)?.setIcon(R.drawable.icon_flights)
      tabLayout?.getTabAt(2)?.setIcon(R.drawable.icon_dictionary)
      val badgeDrawable: BadgeDrawable = tabLayout?.getTabAt(0)!!.orCreateBadge
      badgeDrawable.isVisible = true
      badgeDrawable.number = 12
      val drawerLayout = findViewById&lt;DrawerLayout&gt;(af.azdreams.myconquer.R.id.drawerLayout)
      val toolbar = findViewById&lt;Toolbar&gt;(R.id.toolbar)
      val navView = findViewById&lt;NavigationView&gt;(R.id.navView)
      val toggle = ActionBarDrawerToggle(this,drawerLayout,toolbar, R.string.open, R.string.close)
      toggle.isDrawerIndicatorEnabled = true
      supportActionBar?.setDisplayShowTitleEnabled(false)
      drawerLayout.addDrawerListener(toggle)
      toggle.syncState()
      navView.setNavigationItemSelectedListener {
          when(it.itemId){
              R.id.itmFetch -&gt;startActivity(Intent(this,UserProfileActivity::class.java))
              R.id.itmProfile -&gt;startActivity(Intent(this,Profile::class.java))
              R.id.itmLanguage -&gt;showChangeLanguageDialog()
              R.id.itmAppearance -&gt;chooseThemeDialog()
              R.id.itmSignOut -&gt;basicAlert()
              R.id.itmRateAndComments -&gt;{
                  val url = &quot;https://play.google.com/store/apps/details?id=org.telegram.plus&quot;
                  if (url.startsWith(&quot;https://&quot;) || url.startsWith(&quot;http://&quot;)) {
                      val uri = Uri.parse(url)
                      val intent = Intent(Intent.ACTION_VIEW, uri)
                      startActivity(intent)
                  }
              }
              R.id.itmAbout -&gt;startActivity(Intent(this,About::class.java))
          }
          true
      }
  }
  private var backPressedTime:Long = 0
  private lateinit var backToast: Toast
  override fun onBackPressed() {
      backToast = Toast.makeText(this,resources.getString(R.string.press_back_again_to_leave_the_app), Toast.LENGTH_SHORT)
      if (backPressedTime + 2000 &gt; System.currentTimeMillis()) {
          backToast.cancel()
          super.onBackPressed()
          return
      } else {
          backToast.show()
      }
      backPressedTime = System.currentTimeMillis()
  }
  private fun showChangeLanguageDialog() {
      val pref = getSharedPreferences(&quot;Settings&quot;, MODE_PRIVATE)
      val mBuilder = AlertDialog.Builder(this)
      val listItems = arrayOf(&quot;English&quot;, &quot;فارسی دری&quot;, &quot;پښتو&quot;)
      var checkedItem = 0
      when {
          pref.getString(&quot;My_Lang&quot;, &quot;en&quot;).equals(&quot;en&quot;) -&gt; {
              checkedItem = 0
          }
          pref.getString(&quot;My_Lang&quot;, &quot;en&quot;).equals(&quot;fa&quot;) -&gt; {
              checkedItem = 1
          }
          pref.getString(&quot;My_Lang&quot;, &quot;en&quot;).equals(&quot;ps&quot;) -&gt; {
              checkedItem = 2
          }
      }
      mBuilder.setSingleChoiceItems(listItems, checkedItem) { dialogInterface: DialogInterface, i: Int -&gt;
          when (i) {
              0 -&gt; {
                  setLocale(&quot;en&quot;)
                  startActivity(Intent(this,SplashScreen::class.java))
              }
              1 -&gt; {
                  setLocale(&quot;fa&quot;)
                  startActivity(Intent(this,SplashScreen::class.java))
              }
              2 -&gt; {
                  setLocale(&quot;ps&quot;)
                  startActivity(Intent(this,SplashScreen::class.java))
              }
          }
          dialogInterface.dismiss()
      }
      val mDialog = mBuilder.create()
      mDialog.show()
  }
  private fun setLocale(lang: String?) {
      val locale = Locale(lang)
      Locale.setDefault(locale)
      val config = Configuration()
      config.locale = locale
      baseContext.resources.updateConfiguration(config, baseContext.resources.displayMetrics)
      val editor = getSharedPreferences(&quot;Settings&quot;, MODE_PRIVATE).edit()
      editor.putString(&quot;My_Lang&quot;, lang)
      editor.apply()
  }
  private fun loadLocale() {
      val prefs = getSharedPreferences(&quot;Settings&quot;, MODE_PRIVATE)
      val language = prefs.getString(&quot;My_Lang&quot;, &quot;&quot;)
      setLocale(language)
  }
  private fun basicAlert(){
      val positiveButtonClick = { _: DialogInterface, _: Int -&gt; }
      val negativeButtonClick = { _: DialogInterface, _: Int -&gt; }
      val builder = AlertDialog.Builder(this)
      with(builder) {
          setMessage(R.string.do_you_want_to_sign_out_from_your_my_conquer_account)
          setPositiveButton(R.string.yes, positiveButtonClick)
          setPositiveButton(R.string.yes) { _: DialogInterface, _: Int -&gt;
              auth.signOut()
              startActivity(Intent(this@DashboardActivity, SignInActivity::class.java))
              finish()
          }
          setNegativeButton(R.string.no, negativeButtonClick)
          show()
      }
  }
  private fun initData(){
      auth = FirebaseAuth.getInstance()
      setUserEmail()
  }
  private fun setUserEmail(){
      getCurrentUserEmail()
  }
  private fun getCurrentUserEmail():String? {
      return auth.currentUser?.email
  }
  private fun chooseThemeDialog() {
      val builder = AlertDialog.Builder(this)
      val styles = arrayOf(resources.getString(R.string.light),resources.getString(R.string.dark),resources.getString(
          R.string.system_default))
      val checkedItem = MyPreferences(this).darkMode
      builder.setSingleChoiceItems(styles, checkedItem) { dialog, which -&gt;
          when (which) {
              0 -&gt; {
                  AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
                  MyPreferences(this).darkMode = 0
                  delegate.applyDayNight()
                  dialog.dismiss()
              }
              1 -&gt; {
                  AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
                  MyPreferences(this).darkMode = 1
                  delegate.applyDayNight()
                  dialog.dismiss()
              }
              2 -&gt; {
                  AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
                  MyPreferences(this).darkMode = 2
                  delegate.applyDayNight()
                  dialog.dismiss()
              }
          }
      }
      val dialog = builder.create()
      dialog.show()
  }
  class MyPreferences(context: Context?) {
      companion object {
          private const val DARK_STATUS = &quot;&quot;
      }
      private val preferences = PreferenceManager.getDefaultSharedPreferences(context)
      var darkMode = preferences.getInt(DARK_STATUS, 0)
      set(value) = preferences.edit().putInt(DARK_STATUS, value).apply()
  }
  private fun checkTheme() {
      when (MyPreferences(this).darkMode) {
          0 -&gt; {
              AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
              delegate.applyDayNight()
          }
          1 -&gt; {
              AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
              delegate.applyDayNight()
          }
          2 -&gt; {
              AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
              delegate.applyDayNight()
          }
      }
  }
  private class ViewPagerAdapter(fm: FragmentManager, behavior: Int) :
      FragmentPagerAdapter(fm, behavior) {
      private val fragments: MutableList&lt;Fragment&gt; = ArrayList()
      private val fragmentTitle: MutableList&lt;String&gt; = ArrayList()
      fun addFragment(fragment: Fragment, title: String) {
          fragments.add(fragment)
          fragmentTitle.add(title)
      }
      override fun getItem(position: Int): Fragment {
          return fragments[position]
      }
      override fun getCount(): Int {
          return fragments.size
      }
      override fun getPageTitle(position: Int): CharSequence {
          return fragmentTitle[position]
      }
  }
  private fun getUserData() {
      val scoresRef = Firebase.database.getReference(&quot;Users&quot;)
      scoresRef.child(uid).addValueEventListener(object : ValueEventListener {
          @SuppressLint(&quot;SetTextI18n&quot;)
          override fun onDataChange(snapshot: DataSnapshot) {
              user = snapshot.getValue(User::class.java)!!
              val name = findViewById&lt;TextView&gt;(R.id.tvFirstNameAndLastName)
              val phoneNumber = findViewById&lt;TextView&gt;(R.id.tvPhoneNumber)
              findViewById&lt;TextView&gt;(R.id.tvFirstNameAndLastName)
              name.text = user.name+&quot; &quot;+user.lastName
              phoneNumber.text = user.phoneNumber
              getUserProfile()
          }
          override fun onCancelled(error: DatabaseError) {
              finish()
          }
      })
  }
  private fun getUserProfile() {
  
      val navigationView = binding.navView
      val header: View = navigationView.getHeaderView(0)
      storageReference = FirebaseStorage.getInstance().reference.child(&quot;Users/$uid&quot;)
      val localeFile = File.createTempFile(&quot;tempFile&quot;,&quot;&quot;)
      storageReference.getFile(localeFile).addOnSuccessListener {
          val bitmap = BitmapFactory.decodeFile(localeFile.absolutePath)
          val imageView = header.findViewById&lt;ImageView&gt;(R.id.circleImageView)
          Glide.with(this)
              .load(bitmap)
              .centerCrop()
              .into(imageView)
      }.addOnFailureListener{
          finish()
      }
  }
  private fun onClickListenerSearchUser(){
      binding.btnSearchUsers.setOnClickListener{
          startActivity(Intent(this,SearchUsers::class.java))
      }
  }
  }
  </code></pre>
  <p>and activity_dashboard.xml :</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.drawerlayout.widget.DrawerLayout 
  xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  android:id=&quot;@+id/drawerLayout&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;match_parent&quot;
  tools:context=&quot;.DashboardActivity&quot;&gt;
  &lt;androidx.coordinatorlayout.widget.CoordinatorLayout
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
      &lt;com.google.android.material.appbar.AppBarLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;&gt;
          &lt;androidx.appcompat.widget.Toolbar
              android:id=&quot;@+id/toolbar&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:background=&quot;@color/Orange&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot;&gt;
              &lt;ImageButton
                  android:id=&quot;@+id/btnSearchUsers&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:background=&quot;#0000&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  app:srcCompat=&quot;@drawable/icon_search&quot;
                  android:contentDescription=&quot;@string/todo&quot; /&gt;
          &lt;/androidx.appcompat.widget.Toolbar&gt;
          &lt;com.google.android.material.tabs.TabLayout
              app:tabTextAppearance=&quot;@style/MineCustomTabText&quot;
              android:id=&quot;@+id/tabLayout&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;/&gt;
      &lt;/com.google.android.material.appbar.AppBarLayout&gt;
      &lt;androidx.viewpager.widget.ViewPager
          android:id=&quot;@+id/viewPager&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          app:layout_behavior=&quot;com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior&quot; /&gt;
  &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  &lt;com.google.android.material.navigation.NavigationView
      android:id=&quot;@+id/navView&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;match_parent&quot;
      android:layout_gravity=&quot;start&quot;
      app:headerLayout=&quot;@layout/header&quot;
      app:itemTextAppearance=&quot;@style/menu&quot;
      app:menu=&quot;@menu/nav_menu&quot; /&gt;
  &lt;/androidx.drawerlayout.widget.DrawerLayout&gt;
  </code></pre>