https://github.com/ml-opensource/cutoutviewindicator
Android indicator for ViewPagers and so forth
https://github.com/ml-opensource/cutoutviewindicator
android customizable indicator viewpager
Last synced: 4 months ago
JSON representation
Android indicator for ViewPagers and so forth
- Host: GitHub
- URL: https://github.com/ml-opensource/cutoutviewindicator
- Owner: ml-opensource
- License: apache-2.0
- Created: 2016-07-29T01:06:05.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-10-15T04:41:43.000Z (over 6 years ago)
- Last Synced: 2024-05-07T16:46:45.276Z (almost 2 years ago)
- Topics: android, customizable, indicator, viewpager
- Language: Java
- Size: 607 KB
- Stars: 21
- Watchers: 18
- Forks: 3
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: LICENSE
Awesome Lists containing this project
README
Flexible Indicators for Android
===============================
[](https://travis-ci.org/fuzz-productions/CutoutViewIndicator)
These indicators animate every little touch on your [ViewPager][1].
Want to use a [SpinningViewPager][2] instead? Just [enable an offset][3]
and you're good to go. Need even finer control? Under the hood,
**CutoutViewIndicator** extends LinearLayout; cell styling is done
through LayoutParams. You can set individual values dynamically on
these params and Android's View save/restore state logic will keep
them in order.
You can define each cell directly in your xml file, or add them manually.
Note that the Generators shipped with this library only support
ImageViews and TextViews. We expect the vast majority of integrations
will be satisfied with the default Generator choices.
There is functional support for RecyclerViews in the included
mobile app code - check out [RecyclerStateProxy][4] for details.
Pictures:
---------
The sample mobile app in use:


There's demo source code for mobile under the `mobile` directory; we're
looking to expand compatibility to Android Wear and Android TV too.
Adding to a gradle project:
---------------------------
In your app-level `build.gradle`: ensure your repository list includes
jitpack.io, then add the artifact as a dependency.
```
repositories {
maven {
url "https://jitpack.io"
}
}
```
```
dependencies {
compile 'com.github.fuzz-productions:CutoutViewIndicator:v0.9.0'
}
```
Sample code:
------------
Add a view like this to your xml layout.
```
```
Note that `rcv_drawable` and `rcv_drawable_unselected` default to 0.
You won't see the indicator unless `rcv_drawable` is set to something,
so be sure not to forget about it.
You can leave `rcv_drawable_unselected` equal to 0 if you want a
transparent background.
In your Java (or other JVM-compatible language) file, get a reference
to the view and set it up with a ViewPager.
```
ViewPager pager;
pager.setAdapter(adapter);
// Activity
CutoutViewIndicator cvi = (CutoutViewIndicator) findViewById(R.id.indicator);
cvi.setViewPager(pager);
...
// Fragment
CutoutViewIndicator cvi = (CutoutViewIndicator) view.findViewById(R.id.indicator);
cvi.setViewPager(pager);
...
// DataBinding
CutoutViewIndicator cvi = binding.indicator;
cvi.setViewPager(pager);
```
Then you're good to go. When you're done with the view, it's probably a
good idea to de-initialise the CutoutViewIndicator.
```
cvi.setViewPager(null);
```
If you want to use something other than simple ImageViews, you can
set your own Generator on the object.
```
cvi.setGenerator(new GifGenerator());
```
`ImageCellGenerator` is designed for extensibility - consider
subclassing your custom Generator from that if its views extend
ImageView.
The base library also ships with an experimental CutoutCellGenerator
called `TextCellGenerator`. Check out the javadoc for details on how
to work with it.
License
-------
Copyright 2016-2019 Philip Cohn-Cort and Fuzz Productions
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.
Caveats
-------
Right now it only supports Android SDK 14 and up
(that makes it compatible with Ice Cream Sandwich, Jelly Bean, Lollipop,
Marshmallow, and Nougat), but there's little stopping it from being
backported all the way to APIv11.
Grab a copy of the demo application (live apk coming soon) to try
it in action.
Credit:
-------
This project was inspired by the work of others in the Android community,
especially [ViewPagerIndicator][5] and [AvatarImageView][6].
[1]: https://developer.android.com/reference/android/support/v4/view/ViewPager.html
[2]: https://github.com/eccyan/SpinningTabStrip
[3]: indicator/src/main/java/com/fuzz/indicator/CutoutViewIndicator.java#L593
[4]: mobile/src/main/java/com/fuzz/emptyhusk/prefab/RecyclerStateProxy.java
[5]: https://github.com/JakeWharton/ViewPagerIndicator
[6]: https://github.com/fanrunqi/AvatarImageView