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

  1. <tfoot id='JrOaD'></tfoot>

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

        <bdo id='JrOaD'></bdo><ul id='JrOaD'></ul>
    1. 中心项目更大的Android ViewPager

      时间:2023-10-04

      <tfoot id='YmfRm'></tfoot>

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

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

                本文介绍了中心项目更大的Android ViewPager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想用
                创建一个 ViewPager- 选定的中心项目比其他项目大
                - 以前的部分 &下一项始终可见.

                我正在使用 viewPager.setPageMargin(-20); 来制作 Previous &下一个项目可见.但是,如何使选中的中心项比其他项大一点.

                I want to create a ViewPager with
                - The selected center item being bigger than others
                - Portion of Previous & Next items being always visible.

                I am using viewPager.setPageMargin(-20); to make portion of Previous & Next items visible. But, how to make selected center item little bit bigger than other items.

                推荐答案

                可以在 onPageSelected() 方法中将 Layout 参数设置为大 x%.

                you can set the Layout parameters to be x% bigger in the onPageSelected() method.

                     ViewPager pager ;
                
                    int prevIndex = 0;
                
                    int oldWidth, oldHeight, 
                
                //initialize these to be bigger than the old ones
                
                newWidth, newHeight;
                    pager.setOnPageChangeListener(new OnPageChangeListener() {
                
                        public void onPageSelected(int index) {
                
                // Set the layout params of the newly selected page to be the large width and height
                
                            View v = pager.getChildAt(index);
                
                            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                                    newWidth, newHeight);
                
                            v.setLayoutParams(params);
                
                // Don't forget to set the past view to the old layout params.
                
                            View oldV = pager.getChildAt(prevIndex);
                            RelativeLayout.LayoutParams oldParams = new RelativeLayout.LayoutParams(
                                    oldWidth, oldHeight);
                
                            oldV.setLayoutParams(oldParams);
                
                            prevIndex = index;
                        }
                
                        public void onPageScrolled(int arg0, float arg1, int arg2) {
                            // TODO Auto-generated method stub
                
                        }
                
                        public void onPageScrollStateChanged(int arg0) {
                            // TODO Auto-generated method stub
                
                        }
                    });
                

                这篇关于中心项目更大的Android ViewPager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在 ViewPager 中获取当前可见片段的实例: 下一篇:如何将多个 ViewPagers 放入一个 ScrollView?

                相关文章

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

                    <tfoot id='CMijB'></tfoot>

                  1. <small id='CMijB'></small><noframes id='CMijB'>