https://github.com/markusressel/pageindicatorview
A small, simple, animated page indicator without the need for a viewpager.
https://github.com/markusressel/pageindicatorview
android android-library android-ui pageindicator pageindicatorview view viewpager viewpager-indicator
Last synced: 2 months ago
JSON representation
A small, simple, animated page indicator without the need for a viewpager.
- Host: GitHub
- URL: https://github.com/markusressel/pageindicatorview
- Owner: markusressel
- License: apache-2.0
- Created: 2016-11-10T23:12:52.000Z (almost 9 years ago)
- Default Branch: dev
- Last Pushed: 2023-05-08T07:01:36.000Z (over 2 years ago)
- Last Synced: 2025-04-08T18:09:24.992Z (6 months ago)
- Topics: android, android-library, android-ui, pageindicator, pageindicatorview, view, viewpager, viewpager-indicator
- Language: Kotlin
- Homepage:
- Size: 180 KB
- Stars: 9
- Watchers: 2
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PageIndicatorView
A small, simple, animated page indicator without the need for a viewpager.
# Why
I built this library because I was tired of all the existing page indicators out there
to require a viewpager as this prevented me from using in on an Android Wear project that time.# Usage
To use this view just include it in your depencencies using```groovy
repositories {
...
maven { url "https://jitpack.io" }
}
```
in your project build.gradle file and```groovy
dependencies {
compile 'com.github.markusressel:PageIndicatorView:v1.0.0'
}
```
in your desired module build.gradle file.After successfull gradle build you will be able to use this in your xml layout files
```xml
```
If you want you can change the style of the indicators by using attributes
```xml
```
You can also set these values in code using the following methods:
```kotlin
pageIndicator.activeIndicatorSize = pxFromDp(this, activeIndicatorSize)
pageIndicator.activeIndicatorFillColor = activeIndicatorColorFill
pageIndicator.activeIndicatorStrokeColor = activeIndicatorColorStroke
pageIndicator.activeIndicatorStrokeWidth = pxFromDp(this, activeIndicatorStrokeWidth)pageIndicator.inactiveIndicatorSize = pxFromDp(this, inactiveIndicatorSize)
pageIndicator.inactiveIndicatorFillColor = inactiveIndicatorColorFill
pageIndicator.inactiveIndicatorStrokeColor = inactiveIndicatorColorStroke
pageIndicator.inactiveIndicatorStrokeWidth = pxFromDp(this, inactiveIndicatorStrokeWidth)pageIndicator.indicatorGap = pxFromDp(this, indicatorGap)
pageIndicator.pageCount = pageCount
pageIndicator.setCurrentPage(initialPageIndex) // animated
pageIndicator.setCurrentPage(initialPageIndex, false) // not animated
```To be able to react to "OnClick" events on indicators, you can set a OnIndicatorClickedListener like this:
```kotlin
pageIndicator.setOnIndicatorClickedListener(object : OnIndicatorClickedListener {
override fun onIndicatorClicked(pageIndicatorView: PageIndicatorView, index: Int) {
// set the indicator view to the clicked position
pageIndicatorView.setCurrentPage(index, true)// set your view pager to the clicked position
viewPager.currentItem = index
}
})
```# License
Copyright (c) 2016 Markus Ressel
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.