Space between elements of the indicator
Asked Answered
C

4

8

How to increase/reduce space between elements of the indicator in ViewPagerIndicator?

Casual answered 10/4, 2013 at 13:41 Comment(0)
S
9

I have used CirclePageIndicator. I was able to make more space between two indicator by the step:

  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.

Hope it solved your problem.

Sungsungari answered 21/8, 2015 at 21:2 Comment(0)
K
2

There's no documented way to do this without some digging in.

I think @Md_Omar's answer is wrong as this increases the size of the indicator but not their separating distance.

And you could just use app:radius="5dp" instead if thats what you wanted.

See sample here

https://github.com/JakeWharton/ViewPagerIndicator/blob/master/sample/res/layout/themed_circles.xml

Ka answered 21/7, 2016 at 18:8 Comment(0)
S
1

You can set space by 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);

(I used tabLayout with ViewPager as in this example: Android ViewPager with bottom dots)

Sepoy answered 11/6, 2018 at 9:0 Comment(0)
O
0

If you're using a vector drawable, you can fiddle with the viewportWidth and viewportHeight to create spacing between TabLayout indicators if using the dots style.

Ong answered 6/6, 2019 at 19:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.