Giter VIP home page Giter VIP logo

techscientist / magicindicator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hackware1993/magicindicator

0.0 1.0 0.0 30.28 MB

A powerful, customizable and extensible ViewPager indicator framework —— 强大、可定制、易扩展的 ViewPager 指示器框架。轻轻松松打造各式各样的指示效果。支持角标功能,可将任意的 View 设置成角标。无第三方依赖,兼容 Android 4.0+(更低版本未测试)。进入我的博客 http://hackware.lucode.net 查看关于 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:
final 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 getItemView(Context context, final int index) {
    ClipPagerTitleView clipPagerTitleView = new ClipPagerTitleView(context);
    clipPagerTitleView.setText(mTitleDataList.get(index));
    clipPagerTitleView.setTextColor(Color.parseColor("#f2c4c4"));
    clipPagerTitleView.setClipColor(Color.WHITE);
    clipPagerTitleView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mPager.setCurrentItem(index);
        }
    });
    return clipPagerTitleView;
}

@Override
public IPagerIndicator getIndicator(Context context) {
    return null;
}
});
magicIndicator.setNavigator(commonNavigator);
  1. bind magicindicator to ViewPager:
mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

  @Override
  public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
      magicIndicator.onPageScrolled(position, positionOffset, positionOffsetPixels);
  }

  @Override
  public void onPageSelected(int position) {
      magicIndicator.onPageSelected(position);
  }

  @Override
  public void onPageScrollStateChanged(int state) {
      magicIndicator.onPageScrollStateChanged(state);
  }
});

Now, enjoy yourself!

More effects adding...

Codewake

Who developed?

[email protected]

[email protected]

An intermittent perfectionist.

Visit My Blog for more articles about MagicIndicator.

magicindicator's People

Contributors

hackware1993 avatar

Watchers

Subhash Ramesh 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.