# MagicIndicator
A powerful, customizable and extensible ViewPager indicator framework. As the best alternative of ViewPagerIndicator, TabLayout and PagerSlidingTabStrip.
[Flutter_ConstraintLayout](https://github.com/hackware1993/Flutter_ConstraintLayout) Another very good open source project of mine
[![](https://jitpack.io/v/hackware1993/MagicIndicator.svg)](https://jitpack.io/#hackware1993/MagicIndicator)
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-MagicIndicator-green.svg?style=true)](https://android-arsenal.com/details/1/4252)
[![Codewake](https://www.codewake.com/badges/ask_question.svg)](https://www.codewake.com/p/magicindicator)
![magicindicaotor.gif](https://github.com/hackware1993/MagicIndicator/blob/master/magicindicator.gif)
# Usage
Simple steps, you can integrate **MagicIndicator**:
1. checkout out **MagicIndicator**, which contains source code and demo
2. import module **magicindicator** and add dependency:
```groovy
implementation project(':magicindicator')
```
**or**
```groovy
repositories {
...
maven {
url "https://jitpack.io"
}
}
dependencies {
...
implementation 'com.github.hackware1993:MagicIndicator:1.6.0' // for support lib
implementation 'com.github.hackware1993:MagicIndicator:1.7.0' // for androidx
}
```
3. add **MagicIndicator** to your layout xml:
```xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="net.lucode.hackware.magicindicatordemo.MainActivity">
<net.lucode.hackware.magicindicator.MagicIndicator
android:id="@+id/magic_indicator"
android:layout_width="match_parent"
android:layout_height="40dp" />
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
```
4. find **MagicIndicator** through code, initialize it:
```java
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator);
CommonNavigator commonNavigator = new CommonNavigator(this);
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
@Override
public int getCount() {
return mTitleDataList == null ? 0 : mTitleDataList.size();
}
@Override
public IPagerTitleView getTitleView(Context context, final int index) {
ColorTransitionPagerTitleView colorTransitionPagerTitleView = new ColorTransitionPagerTitleView(context);
colorTransitionPagerTitleView.setNormalColor(Color.GRAY);
colorTransitionPagerTitleView.setSelectedColor(Color.BLACK);
colorTransitionPagerTitleView.setText(mTitleDataList.get(index));
colorTransitionPagerTitleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mViewPager.setCurrentItem(index);
}
});
return colorTransitionPagerTitleView;
}
@Override
public IPagerIndicator getIndicator(Context context) {
LinePagerIndicator indicator = new LinePagerIndicator(context);
indicator.setMode(LinePagerIndicator.MODE_WRAP_CONTENT);
return indicator;
}
});
magicIndicator.setNavigator(commonNavigator);
```
5. work with ViewPager:
```java
ViewPagerHelper.bind(magicIndicator, mViewPager);
```
**or**
work with Fragment Container(switch Fragment by hide()、show()):
```java
mFramentContainerHelper = new FragmentContainerHelper(magicIndicator);
// ...
mFragmentContainerHelper.handlePageSelected(pageIndex); // invoke when switch Fragment
```
# Extend
**MagicIndicator** can be easily extended:
1. implement **IPagerTitleView** to customize tab:
```java
public class MyPagerTitleView extends View implements IPagerTitleView {
public MyPagerTitleView(Context context) {
super(context);
}
@Override
public void onLeave(int index, int totalCount, float leavePercent, boolean leftToRight) {
}
@Override
public void onEnter(int index, int totalCount, float enterPercent, boolean leftToRight) {
}
@Override
public void onSelected(int index, int totalCount) {
}
@Override
public void onDeselected(int index, int totalCount) {
}
}
```
2. implement **IPagerIndicator** to customize indicator:
```java
public class MyPagerIndicator extends View implements IPagerIndicator {
public MyPagerIndicator(Context context) {
super(context);
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
@Override
public void onPositionDataProvide(List<PositionData> dataList) {
}
}
```
3. use **CommonPagerTitleView** to load custom layout xml.
Now, enjoy yourself!
See extensions in [*app/src/main/java/net/lucode/hackware/magicindicatordemo/ext*](https://github.com/hackware1993/MagicIndicator/tree/master/app/src/main/java/net/lucode/hackware/magicindicatordemo/ext),more extensions adding...
# Who developed?
[email protected]
[email protected]
Q&A <a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=7ac5bef0321c7afa7e9fc4e94175fa36f413e3330c82e828b1743274af8a64d7"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="MagicIndicator交流群" title="MagicIndicator交流群"></a>
An intermittent perfectionist.
Visit [My Blog](http://hackware.lucode.net) for more articles about MagicIndicator.
# License
```
MIT License
Copyright (c) 2016 hackware1993
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
# More
Have seen here, give a star?(都看到这儿了,何不给个...,哎,别走啊,star还没...)
没有合适的资源?快使用搜索试试~ 我知道了~
Android几乎所有的开源项目的导航类目录 底部导航 顶部导航动画
共735个文件
flat:150个
json:123个
class:110个
需积分: 5 0 下载量 6 浏览量
2023-09-22
09:02:00
上传
评论
收藏 12.63MB RAR 举报
温馨提示
非常实用
资源推荐
资源详情
资源评论
收起资源包目录
Android几乎所有的开源项目的导航类目录 底部导航 顶部导航动画 (735个子文件)
0QHD+KCoHIya9LMm7QaDKPob+os= 9KB
0QHD+KCoHIya9LMm7QaDKPob+os= 9KB
1tC9Pgy5NALK_ZPV0Jf+cmDQNPI= 665KB
1tC9Pgy5NALK_ZPV0Jf+cmDQNPI= 665KB
aB0NrnSy47IKfLti+_fcnAraumA= 31KB
aB0NrnSy47IKfLti+_fcnAraumA= 31KB
androidResources 26KB
aoFH2xAmOr9GQLOZvFj8cmM79dI= 54KB
aoFH2xAmOr9GQLOZvFj8cmM79dI= 54KB
resources-debug.ap_ 452KB
app-debug.apk 1.6MB
demo.apk 1.07MB
b8kIETrd8XWtuR1kcb5B_qM2Ymk= 21KB
b8kIETrd8XWtuR1kcb5B_qM2Ymk= 21KB
gradlew.bat 2KB
executionHistory.bin 1.26MB
classAnalysis.bin 769KB
jarAnalysis.bin 130KB
fileHashes.bin 80KB
outputFiles.bin 57KB
taskHistory.bin 28KB
resourceHashesCache.bin 19KB
6d317aa41db4d05b6c8ab4b5595d62c9.bin 11B
last-build.bin 1B
BxieYSrD_GTw5oXnW2iBduW1K0Q= 7KB
BxieYSrD_GTw5oXnW2iBduW1K0Q= 7KB
Ck3MBg4yLIMerw0uA9mHPAE_1ns= 9KB
Ck3MBg4yLIMerw0uA9mHPAE_1ns= 9KB
CommonNavigator.class 13KB
ScaleCircleNavigator.class 9KB
CircleNavigator.class 8KB
LinePagerIndicator.class 7KB
BadgePagerTitleView.class 6KB
FragmentContainerHelper.class 6KB
ScrollableTabExampleActivity.class 6KB
BezierPagerIndicator.class 6KB
CommonPagerIndicator.class 6KB
FixedTabExampleActivity.class 6KB
ClipPagerTitleView.class 5KB
TriangularPagerIndicator.class 5KB
BadgeTabExampleActivity$1.class 5KB
WrapPagerIndicator.class 5KB
BadgeTabExampleActivity$2.class 5KB
LoadCustomLayoutExampleActivity.class 5KB
BadgeTabExampleActivity.class 5KB
FragmentContainerExampleActivity.class 5KB
DummyCircleNavigator.class 5KB
CustomNavigatorExampleActivity.class 5KB
CommonPagerTitleView.class 4KB
DynamicTabExampleActivity.class 4KB
NavigatorHelper.class 4KB
SimplePagerTitleView.class 4KB
TestPagerIndicator.class 4KB
BadgeTabExampleActivity$3.class 4KB
LoadCustomLayoutExampleActivity$1.class 4KB
FixedTabExampleActivity$2.class 4KB
ScrollableTabExampleActivity$7.class 3KB
ScrollableTabExampleActivity$5.class 3KB
NoTabOnlyIndicatorExampleActivity.class 3KB
FixedTabExampleActivity$3.class 3KB
FragmentContainerExampleActivity$1.class 3KB
BadgeTabExampleActivity$4.class 3KB
ScrollableTabExampleActivity$2.class 3KB
ScrollableTabExampleActivity$6.class 3KB
DotPagerIndicator.class 3KB
FixedTabExampleActivity$4.class 3KB
ScrollableTabExampleActivity$4.class 3KB
FixedTabExampleActivity$1.class 3KB
ScrollableTabExampleActivity$3.class 3KB
ScrollableTabExampleActivity$8.class 3KB
ScrollableTabExampleActivity$9.class 3KB
NoTabOnlyIndicatorExampleActivity$2.class 3KB
NoTabOnlyIndicatorExampleActivity$1.class 3KB
ExamplePagerAdapter.class 2KB
ScrollableTabExampleActivity$1.class 2KB
DynamicTabExampleActivity$1.class 2KB
MagicIndicator.class 2KB
LoadCustomLayoutExampleActivity$1$1.class 2KB
BadgeAnchor.class 2KB
ExampleMainActivity.class 2KB
BadgeTabExampleActivity$1$1.class 2KB
TestFragment2.class 2KB
TestFragment4.class 2KB
TestFragment3.class 2KB
TestFragment.class 2KB
FragmentContainerExampleActivity$1$1.class 2KB
LoadCustomLayoutExampleActivity$1$2.class 2KB
CommonNavigatorAdapter.class 2KB
ScrollableTabExampleActivity$4$1.class 2KB
ScrollableTabExampleActivity$1$1.class 2KB
ScrollableTabExampleActivity$6$1.class 2KB
ScrollableTabExampleActivity$7$1.class 2KB
ScrollableTabExampleActivity$3$1.class 2KB
ScrollableTabExampleActivity$9$1.class 2KB
ScrollableTabExampleActivity$8$1.class 2KB
ScrollableTabExampleActivity$5$1.class 2KB
ScrollableTabExampleActivity$2$1.class 2KB
DynamicTabExampleActivity$1$1.class 2KB
FixedTabExampleActivity$2$1.class 1KB
FixedTabExampleActivity$3$1.class 1KB
共 735 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
a8601689
- 粉丝: 0
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功