• <small id='c7hBG'></small><noframes id='c7hBG'>

      <bdo id='c7hBG'></bdo><ul id='c7hBG'></ul>

    <tfoot id='c7hBG'></tfoot>

      <legend id='c7hBG'><style id='c7hBG'><dir id='c7hBG'><q id='c7hBG'></q></dir></style></legend>
    1. <i id='c7hBG'><tr id='c7hBG'><dt id='c7hBG'><q id='c7hBG'><span id='c7hBG'><b id='c7hBG'><form id='c7hBG'><ins id='c7hBG'></ins><ul id='c7hBG'></ul><sub id='c7hBG'></sub></form><legend id='c7hBG'></legend><bdo id='c7hBG'><pre id='c7hBG'><center id='c7hBG'></center></pre></bdo></b><th id='c7hBG'></th></span></q></dt></tr></i><div id='c7hBG'><tfoot id='c7hBG'></tfoot><dl id='c7hBG'><fieldset id='c7hBG'></fieldset></dl></div>
      1. 更改 viewPager 滑动方向

        时间:2023-10-04

          • <bdo id='7V2jJ'></bdo><ul id='7V2jJ'></ul>

              <i id='7V2jJ'><tr id='7V2jJ'><dt id='7V2jJ'><q id='7V2jJ'><span id='7V2jJ'><b id='7V2jJ'><form id='7V2jJ'><ins id='7V2jJ'></ins><ul id='7V2jJ'></ul><sub id='7V2jJ'></sub></form><legend id='7V2jJ'></legend><bdo id='7V2jJ'><pre id='7V2jJ'><center id='7V2jJ'></center></pre></bdo></b><th id='7V2jJ'></th></span></q></dt></tr></i><div id='7V2jJ'><tfoot id='7V2jJ'></tfoot><dl id='7V2jJ'><fieldset id='7V2jJ'></fieldset></dl></div>
            • <legend id='7V2jJ'><style id='7V2jJ'><dir id='7V2jJ'><q id='7V2jJ'></q></dir></style></legend>

              <small id='7V2jJ'></small><noframes id='7V2jJ'>

                <tbody id='7V2jJ'></tbody>

                  <tfoot id='7V2jJ'></tfoot>
                  本文介绍了更改 viewPager 滑动方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 TabLayout 和 viewPager 以及向左或向右滑动 viewPager 以在页面之间导航的选项.

                  I'm using TabLayout and viewPager with an option to swipe the viewPager to the left or right in order to navigate between pages.

                  我的问题是,我的应用程序是基于 RTL(从右到左)并且滑动方向是相反的.

                  My problem is, that my application is RTL based (right-to-left) and the swipe direction is reversed.

                  我正在尝试将滑动方向从默认更改为反向版本.我在网上搜索了很多,但找不到方法.

                  I'm trying to change the swipe direction from the default to the reversed version. I've been searching alot on the web and couldn't find a way how to do it.

                  我正在使用 android.support.v4.view.ViewPager;

                  这就是我使用 viewPager 初始化 TabLayout 的方式:

                  and this is how I initialize my TabLayout with the viewPager:

                  // View Page Adapter
                          final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
                          final PagerAdapter adapter = new PagerAdapter
                                  (getSupportFragmentManager(), tabLayout.getTabCount());
                          //View Page Adapter Configuration
                          viewPager.setAdapter(adapter);
                          viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
                          viewPager.setOffscreenPageLimit(3);
                          tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                              @Override
                              public void onTabSelected(TabLayout.Tab tab) {
                                  viewPager.setCurrentItem(tab.getPosition());
                              }
                  

                  总结:目前,当我向左滑动 viewPager 时,它会显示下一页.在 RTL 中,当您向右滑动 viewPager 时,它会显示下一页.

                  Summary: Currently, When I'm swiping the viewPager to the left, it shows the next page. in RTL, when you swipe the viewPager to the right, it shows the next page.

                  这可能很难理解,但就是这样.向右滑动显示下一页

                  It might be hard to understand, but here it is. Swiping right shows the next page

                  而我需要向右滑动才能显示上一页.

                  while I need swiping right to show the previous page.

                  推荐答案

                  改变Viewpager的滑动方向是非常简单的技术.

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

                  有两个简单的步骤必须跟随你,

                  There are two simple step which have to follow you,

                  1.改变View pager的旋转,

                  1. Change the rotation of the View pager,

                  viewpager.setRotationY(180);
                  

                  2.然后再改变viewpager的子片段容器的方向,

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

                  recyclerView.setRotationY(180);
                  

                  注意:在我的例子中,我使用 recyclerview 作为视图寻呼机的子级.

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

                  这对我来说是 100% 的.

                  This is 100% worked for me.

                  这篇关于更改 viewPager 滑动方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:带有视图模型和实时数据的 ViewPager,所有 6 个选项卡数据都替换为最后一个选项卡数据 下一篇:Android ViewPager with ScrollViews with ViewPagers inside th

                  相关文章

                  <i id='fogRa'><tr id='fogRa'><dt id='fogRa'><q id='fogRa'><span id='fogRa'><b id='fogRa'><form id='fogRa'><ins id='fogRa'></ins><ul id='fogRa'></ul><sub id='fogRa'></sub></form><legend id='fogRa'></legend><bdo id='fogRa'><pre id='fogRa'><center id='fogRa'></center></pre></bdo></b><th id='fogRa'></th></span></q></dt></tr></i><div id='fogRa'><tfoot id='fogRa'></tfoot><dl id='fogRa'><fieldset id='fogRa'></fieldset></dl></div>
                1. <tfoot id='fogRa'></tfoot>
                  • <bdo id='fogRa'></bdo><ul id='fogRa'></ul>

                      <legend id='fogRa'><style id='fogRa'><dir id='fogRa'><q id='fogRa'></q></dir></style></legend>

                      <small id='fogRa'></small><noframes id='fogRa'>