Skip to content

Pager indicator view for android, compatible with support v4 ViewPager

License

Notifications You must be signed in to change notification settings

sbbqq/AndroidViewPagerIndicator

 
 

Repository files navigation

Android View Pager Indicator

Pager indicator view for android, compatible with support v4 ViewPager

Demo

Usage (Dependencies)

  • Add the following to your project level build.gradle:
allprojects {
	repositories {
		maven { url "https://jitpack.io" }
	}
}
  • Add this to your app build.gradle:
dependencies {

  implementation "com.github.JeovaniMartinez:AndroidViewPagerIndicator:0.1.0"
  
  //The library need this dependencies, use the latest version
  implementation 'com.android.support:appcompat-v7:27.1.1'
  implementation 'com.android.support.constraint:constraint-layout:1.1.0'
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.31"
  implementation "org.jetbrains.anko:anko:0.10.4"
}

Getting Started

  • In your layout:
<info.jeovani.viewpagerindicator.ViewPagerIndicator
        android:id="@+id/mViewPagerIndicator"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        app:vpi_items_count="5"
        app:vpi_view_pager="@+id/mViewPager" />

<!--Note: vpi_items_count is necessary to show a preview in the xml design-->
  • In your java class:
 ViewPagerIndicator mViewPagerIndicator;
 
 mViewPagerIndicator = findViewById(R.id.mViewPagerIndicator);
 mViewPagerIndicator.setItemsCount(5); //Total elements of your ViewPager adapter
  • Or in your kotlin class:
 mViewPagerIndicator.itemsCount = 5 //Total elements of your ViewPager adapter

That's all you need for basic the implementation, the library will react by changing the selected item when ViewPager page change

Customize

Methods Java/Kotlin XML attribute Description
setViewPager()
viewPager
vpi_view_pager ViewPager to associate pager
setItemsCount()
itemsCount
vpi_items_count Total ViewPager adapter elements
setItemSelected()
itemSelected
vpi_item_selected Current position selected
setItemType()
itemType
vpi_item_type Item shape, use PagerItemType.OVAL or PagerItemType.RECTANGLE, in XML use oval or rectangle
setOrientation()
orientation
vpi_orientation Items orientation, use PagerOrientation.HORIZONTAL or PagerOrientation.VERTICAL, in XML use horizontal or vertical
setItemSelectedColors()
itemSelectedColors
vpi_selected_primary_color
vpi_selected_secondary_color
Array of colors for the selected element of the pager, use one color for solid and two for gradient, in XML can define one or both colors separately
setItemsUnselectedColors()
itemsUnselectedColors
vpi_unselected_primary_color
vpi_unselected_secondary_color
Array of colors for the unselected elements of the pager, use one color for solid and two for gradient, in XML can define one or both colors separately
setItemElevation()
itemElevation
vpi_item_elevation Elevation for each item, in code use a integer and the unity is converted to dp, in XML use dp
setItemWidth()
itemWidth
vpi_item_width Width for each item, in code use a integer the library convert the unity to dp, in XML use dp
setItemHeight()
itemHeight
vpi_item_height Height for each item, in code use a integer the library convert the unity to dp, in XML use dp
setItemMargin()
itemMargin
vpi_item_margin Margin for each item, in code use a integer the library convert the unity to dp, in XML use dp

License

Copyright 2018 Jeovani Martínez

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.

About

Pager indicator view for android, compatible with support v4 ViewPager

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 100.0%