Giter Club home page Giter Club logo

ccvg007 / magicindicator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hackware1993/magicindicator

0.0 2.0 0.0 30.34 MB

A powerful, customizable and extensible ViewPager indicator framework —— 强大、可定制、易扩展的 ViewPager 指示器框架。轻轻松松打造各式各样的指示效果。支持角标功能,可将任意的 View 设置成角标。无第三方依赖,兼容 Android 4.0+(更低版本未测试)。进入我的博客 http://www.jianshu.com/users/f0a3fb1abaed 查看关于 MagicIndicator 的更多文章 >>>

Java 100.00%

magicindicator's Introduction

MagicIndicator

A powerful, customizable and extensible ViewPager indicator framework.

magicindicaotor.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:
compile project(':magicindicator')
  1. add magicindicator to your layout 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>
  1. find magicindicator through code, initialize it:
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);
  1. bind magicindicator to ViewPager:
SimpleViewPagerDelegate.with(magicIndicator, mViewPager).delegate();

Now, enjoy yourself!

More effects adding...

Codewake

Who developed?

[email protected]

[email protected]

QQ Group:373360748

An intermittent perfectionist.

Visit My Blog for more articles about MagicIndicator.

magicindicator's People

Contributors

hackware1993 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.