https://github.com/pengmaster/multiindicator
多功能指示器,适用于ViewPager 多场景
https://github.com/pengmaster/multiindicator
indicator multiindicator viewpager viewpager-indicator
Last synced: about 1 year ago
JSON representation
多功能指示器,适用于ViewPager 多场景
- Host: GitHub
- URL: https://github.com/pengmaster/multiindicator
- Owner: pengMaster
- Created: 2019-05-28T07:35:24.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-29T06:48:48.000Z (about 7 years ago)
- Last Synced: 2025-03-18T00:46:09.678Z (about 1 year ago)
- Topics: indicator, multiindicator, viewpager, viewpager-indicator
- Language: Java
- Homepage:
- Size: 213 KB
- Stars: 47
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ViewPager指示器有这一篇就够了
多功能指示器,适用于ViewPager 多场景
- 传统的文字+指示器组合
- 单纯的指示器
- 圆点轮播指示器
## 1.传统的文字+指示器组合
xml:
```java
```
java:
```java
List lists = new ArrayList<>();
Fragment fragment1 = new TestFragment();
Fragment fragment2 = new TestFragment();
Fragment fragment3 = new TestFragment();
lists.add(fragment1);
lists.add(fragment2);
lists.add(fragment3);
BaseFragmentAdapter adapter = new BaseFragmentAdapter(getSupportFragmentManager(),lists);
mViewPager.setAdapter(adapter);
mCenterTabLayout.setViewPager(mViewPager, 1);
```
扩展属性:
```java
mTabLayout.setTitles("Tab1", "Tab2", "Tab3");
mTabLayout.setTabIndex(0, true);
mTabLayout.setTitleSize(15);
mTabLayout.setStripColor(Color.RED);
mTabLayout.setStripWeight(6);
mTabLayout.setStripFactor(2);
mTabLayout.setStripType(TabLayout.StripType.LINE);
mTabLayout.setStripGravity(TabLayout.StripGravity.BOTTOM);
mTabLayout.setTypeface("fonts/typeface.ttf");
mTabLayout.setCornersRadius(3);
mTabLayout.setAnimationDuration(300);
mTabLayout.setInactiveColor(Color.GRAY);
mTabLayout.setActiveColor(Color.WHITE);
mTabLayout.setOnPageChangeListener(...);
mTabLayout.setOnTabStripSelectedIndexListener(...);
```
```
如果产品经理再次提出了`花里胡哨`的需求,那么上面的指示器就无法满足要求,为了高度解耦,
我们单纯的把指示器拿出来,然后我们就可以肆意妄为了,如下:
```
## 2.单纯的指示器
xml:
```java
lists = new ArrayList<>();
Fragment fragment1 = new TestFragment();
Fragment fragment2 = new TestFragment();
lists.add(fragment1);
lists.add(fragment2);
BaseFragmentAdapter adapter = new BaseFragmentAdapter(getSupportFragmentManager(),lists);
ViewPager vpPersonManager = findViewById(R.id.vpPersonManager);
TabView tabView = findViewById(R.id.mIndicator);
vpPersonManager.setAdapter(adapter);
tabView.setViewPager(vpPersonManager);
```
扩展属性:
```java
app:tabHeight="3dp"
app:tabColor="@color/red"
app:tabRadius="20dp"
```
## 3.圆点轮播指示器
扩展属性以及效果图:
Name| Support version| Preview
-------- | --- | ---
`AnimationType.NONE`| 0.0.1 | 
`AnimationType.COLOR`| 0.0.1 |
`AnimationType.SCALE`| 0.0.1 |
`AnimationType.SLIDE`| 0.0.1 |
`AnimationType.WORM`| 0.0.1 |
`AnimationType.FILL`| 0.0.1 |
`AnimationType.THIN_WORM`| 0.0.1 |
`AnimationType.DROP`| 0.0.1 |
`AnimationType.SWAP`| 0.0.1 |
xml:
```java
```
java:
```java
pageIndicatorView.setAnimationType(customization.getAnimationType());
pageIndicatorView.setOrientation(customization.getOrientation());
pageIndicatorView.setRtlMode(customization.getRtlMode());
pageIndicatorView.setInteractiveAnimation(customization.isInteractiveAnimation());
pageIndicatorView.setAutoVisibility(customization.isAutoVisibility());
pageIndicatorView.setFadeOnIdle(customization.isFadeOnIdle());
```
## 通用配置:
1. project build.gradle
```java
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```
2. app build.gradle
```java
dependencies {
implementation 'com.github.pengMaster:MultiIndicator:0.0.1'
}
```
## 如果存在appcompat-v7 jar包冲突:
```java
implementation ('com.github.pengMaster:MultiIndicator:0.0.1'){
exclude(module:'com.android.support:appcompat-v7')
}
```
## Issues
这么帅气的你,都看到这里了,给个star呗,乡里乡亲的.....