Skip to content

Latest commit

 

History

History
102 lines (69 loc) · 3.18 KB

File metadata and controls

102 lines (69 loc) · 3.18 KB

ViewPagerIndicator

A lightweight paging indicator view for the ViewPager from the Android Support Library.

This is an extremely lightweight implementation that displays the pages as horizontally aligned dots. If you need more control over the paging indicator's display checkout Jake Wharton's Android ViewPagerIndicator on which this implementation is based.

ViewPagerIndicator Screenshot

Usage

There is a sample app provided which demonstrates how to use the library.

Here are the steps required to add a ViewPagerIndicator to a ViewPager:

  1. Add ViewPagerIndicator to your view right below the respective ViewPager:
<com.github.segoh.viewpagerindicator.ViewPagerIndicator
    android:id="@+id/pager_indicator"
    android:layout_height="wrap_content"
    android:layout_width="match_parent" />
  1. Bind the ViewPagerIndicator to your ViewPager:
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);

    // Add an adapter to your pager
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new PageAdapter(getSupportFragmentManager()));

    // Bind the pager indicator to your pager
    ViewPagerIndicator pagerIndicator = (ViewPagerIndicator) findViewById(R.id.pager_indicator);
    pagerIndicator.setViewPager(pager);
}

Please note: If you require an OnPageChangeListener on your ViewPager set it on the ViewPagerIndicator rather than on the ViewPager.

Credits

License

Copyright 2014 Sebastian Gutsfeld
Copyright 2012 Jake Wharton
Copyright 2011 Patrik Åkerfeldt
Copyright 2011 Francisco Figueiredo Jr.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.