如何在ViewPagerIndicator中增加/减少指示器元素之间的间距?
CirclePageIndicator
。我可以通过以下步骤使两个指示器之间的间距更大:
Open the source code of CirclePageIndicator
and find the variable mRadius
At the line number around 235, you will find a line like below:
final float threeRadius = mRadius * (some value here)
5
for my case, it gave me a good result.
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。