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

    1. <tfoot id='7wZj4'></tfoot>

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

      1. 如何在android滑动选项卡布局中对齐活动选项卡中心

        How to align active tab center in android Sliding Tab Layout(如何在android滑动选项卡布局中对齐活动选项卡中心)
        • <bdo id='EzN8V'></bdo><ul id='EzN8V'></ul>
          <legend id='EzN8V'><style id='EzN8V'><dir id='EzN8V'><q id='EzN8V'></q></dir></style></legend>
            <tbody id='EzN8V'></tbody>

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

                <tfoot id='EzN8V'></tfoot>

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

                  本文介绍了如何在android滑动选项卡布局中对齐活动选项卡中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I have 12 items in android sliding tab layout + view pager. While sliding from left to right, selected tab should be center same as play store. Please help me how to do that. In my application active tab is always left of the screen.

                  解决方案

                  My approach differs a bit of the Shripad Bhat solution, which bounce the tab at the end of the slide.

                  Here's my workaround...

                  Changes to onPageScrolled method:

                  @Override
                  public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                      int tabStripChildCount = mTabStrip.getChildCount();
                      if ((tabStripChildCount == 0) || (position < 0) || (position >= tabStripChildCount)) {
                          return;
                      }
                  
                      mTabStrip.onViewPagerPageChanged(position, positionOffset);
                  
                      View selectedTitle = mTabStrip.getChildAt(position);
                      int selectedOffset = (selectedTitle == null) ? 0 : selectedTitle.getWidth();
                      int nextTitlePosition = position + 1;
                      View nextTitle = mTabStrip.getChildAt(nextTitlePosition);
                      int nextOffset = (nextTitle == null) ? 0 : nextTitle.getWidth();
                      int extraOffset = (int)(0.5F * (positionOffset * (float)(selectedOffset + nextOffset)));
                      scrollToTab(position, extraOffset);
                  
                      if (mViewPagerPageChangeListener != null) {
                          mViewPagerPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
                      }
                  }
                  

                  Changes to scrollToTab method:

                  private int mLastScrollTo;
                  
                  private void scrollToTab(int tabIndex, int positionOffset) {
                      final int tabStripChildCount = mTabStrip.getChildCount();
                      if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
                          return;
                      }
                  
                      View selectedChild = mTabStrip.getChildAt(tabIndex);
                      if (selectedChild != null && selectedChild.getMeasuredWidth() != 0) {
                  
                          int targetScrollX = ((positionOffset + selectedChild.getLeft()) - getWidth() / 2) + selectedChild.getWidth() / 2;
                  
                          if (targetScrollX != mLastScrollTo) {
                              scrollTo(targetScrollX, 0);
                              mLastScrollTo = targetScrollX;
                          }
                      }
                  }
                  

                  这篇关于如何在android滑动选项卡布局中对齐活动选项卡中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
                  Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)
                  How can i use MYSQL database connection in iphone application useing cocos2d?(如何在使用 cocos2d 的 iphone 应用程序中使用 MYSQL 数据库连接?)
                  Smoothly drag a Sprite in cocos2d - iPhone(在 cocos2d 中平滑拖动一个 Sprite - iPhone)
                  Cocos2D complex animations(Cocos2D 复杂动画)

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

                  <tfoot id='VHCib'></tfoot>

                          <tbody id='VHCib'></tbody>

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