指示器元素之间的间距

8
如何在ViewPagerIndicator中增加/减少指示器元素之间的间距?
4个回答

9
我使用了CirclePageIndicator。我可以通过以下步骤使两个指示器之间的间距更大:
  1. Open the source code of CirclePageIndicator and find the variable mRadius

  2. At the line number around 235, you will find a line like below:

    final float threeRadius = mRadius * (some value here)
    
  3. Change this some value, and play with it. I used 5 for my case, it gave me a good result.
希望这能解决你的问题。

2

1
您可以通过LayoutParams设置空间:

int numOfIndicators = 5;
int space = 20;

tabLayout.setupWithViewPager(myViewPager, true);
ConstraintLayout.LayoutParams params = 
         (ConstraintLayout.LayoutParams)tabLayout.getLayoutParams();//ConstraintLayout is my layout manager
params.width = numOfIndicators * space;
tabLayout.setLayoutParams(params);

我使用了TabLayout和ViewPager,就像这个例子一样: Android ViewPager with bottom dots


0
如果您正在使用矢量可绘制对象,可以通过调整viewportWidth和viewportHeight来在使用点样式的TabLayout指示器之间创建间距。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接