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

<tfoot id='jKzMZ'></tfoot>
<legend id='jKzMZ'><style id='jKzMZ'><dir id='jKzMZ'><q id='jKzMZ'></q></dir></style></legend>

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

    1. <i id='jKzMZ'><tr id='jKzMZ'><dt id='jKzMZ'><q id='jKzMZ'><span id='jKzMZ'><b id='jKzMZ'><form id='jKzMZ'><ins id='jKzMZ'></ins><ul id='jKzMZ'></ul><sub id='jKzMZ'></sub></form><legend id='jKzMZ'></legend><bdo id='jKzMZ'><pre id='jKzMZ'><center id='jKzMZ'></center></pre></bdo></b><th id='jKzMZ'></th></span></q></dt></tr></i><div id='jKzMZ'><tfoot id='jKzMZ'></tfoot><dl id='jKzMZ'><fieldset id='jKzMZ'></fieldset></dl></div>
    2. 将drawable添加到CirclePageIndicator

      时间:2023-10-04

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

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

                本文介绍了将drawable添加到CirclePageIndicator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如何将图像添加到圆形页面指示符而不是添加颜色.. 我尝试添加图标页面指示符,但点击方法不起作用,但我可以添加图像..在 circlepageIndicator 中,onclick 方法有效,但如何将可绘制的图像添加到 CIRCLEPAGE INDICATOR.以下是我的代码.

                How to add image to circle pageindicator instead of adding color.. I have tried to add iconpage indicator but on click method is not working but i can add Image.. In circlepageIndicator onclick method is working but HOW TO ADD DRAWABLE, IMAGE TO CIRCLEPAGE INDICATOR. BELOW IS MY CODE.

                使用圆形页面指示符

                       indicator  = (CirclePageIndicator)findViewById(R.id.indicatorMenu);
                    indicator.setViewPager(pagerMenu);
                
                    final float density1 = getResources().getDisplayMetrics().density;
                    indicator.setRadius(5 * density1);
                    indicator.setPageColor(0xFF000000);
                    indicator.setFillColor(0xFF888888);
                  indicator.setStrokeColor(0x880000FF);
                    indicator.setStrokeWidth(2 * density1);
                
                    //We set this on the indicator, NOT the pager
                    indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {             
                        @Override
                        public void onPageSelected(int position) {
                         //   Toast.makeText(HomeSpizzaView.this, "Changed to page " + position, Toast.LENGTH_SHORT).show();
                        //  pagerMenu.setCurrentItem(position, false);            
                        }
                        @Override
                        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                        }
                        @Override
                        public void onPageScrollStateChanged(int state) {               
                        }
                    });
                
                    indicator.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            int currentItem = pagerMenu.getCurrentItem();
                               int totalItems = pagerMenu.getAdapter().getCount();
                               int nextItem = (currentItem + 1) % totalItems;
                               pagerMenu.setCurrentItem(nextItem);
                         Log.i("kkkkk", "getCurrentItem"+  nextItem);
                         Toast.makeText(HomeSpizzaView.this, "getCurrentItem"+  nextItem, Toast.LENGTH_SHORT).show();
                        }
                    });
                

                使用的图标页面指示器

                      mIndicator  = (IconPageIndicator)findViewById(R.id.indicator);
                    mIndicator.setViewPager(mPager);
                    mIndicator.setLongClickable(true);
                
                    //We set this on the indicator, NOT the pager
                    mIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {             
                        @Override
                        public void onPageSelected(int position) {
                            Toast.makeText(HomeSpizzaView.this, "Changed to page " + position, Toast.LENGTH_SHORT).show();
                            mPager.setCurrentItem(position, false);    
                        }
                        @Override
                        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                        }
                        @Override
                        public void onPageScrollStateChanged(int state) {               
                        }
                    });
                
                
                    mIndicator.setOnClickListener(new View.OnClickListener(){
                        @Override
                        public void onClick(View v) {
                            int currentItem = pagerMenu.getCurrentItem();
                               int totalItems = pagerMenu.getAdapter().getCount();
                               int nextItem = (currentItem + 1) % totalItems;
                               pagerMenu.setCurrentItem(nextItem);
                         Log.i("mmmmmmmmmmmm", "getCurrentItem"+  nextItem);
                         Toast.makeText(HomeSpizzaView.this, "getCurrentItem"+  nextItem, Toast.LENGTH_SHORT).show();
                
                        }
                
                    });
                

                推荐答案

                我遇到了同样的问题,唯一的解决方案是创建自己的库来解决这个问题.

                I had the same problem and the only solution was to create my own library to do that.

                https://github.com/augustopicciani/DrawablePageIndicator

                这篇关于将drawable添加到CirclePageIndicator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:ViewPager 中的 ScrollView:滑动不起作用 下一篇:如何在 ViewPager 中获取当前可见片段的实例:

                相关文章

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

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

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

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