Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/YvesCheung/RollingText
Android TextView with rolling animation
https://github.com/YvesCheung/RollingText
animation number rollingtextview scrollingtextview
Last synced: 9 days ago
JSON representation
Android TextView with rolling animation
- Host: GitHub
- URL: https://github.com/YvesCheung/RollingText
- Owner: YvesCheung
- License: apache-2.0
- Created: 2018-02-28T10:45:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-09-05T08:22:38.000Z (about 1 year ago)
- Last Synced: 2024-08-01T19:45:57.792Z (4 months ago)
- Topics: animation, number, rollingtextview, scrollingtextview
- Language: Kotlin
- Homepage:
- Size: 2.48 MB
- Stars: 920
- Watchers: 9
- Forks: 77
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - YvesCheung/RollingText - Android TextView with rolling animation (Kotlin)
README
# RollingTextView
---
![preview][1]
[![](https://jitpack.io/v/YvesCheung/RollingText.svg)](https://jitpack.io/#YvesCheung/RollingText)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.yvescheung/RollingText.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.github.yvescheung%22%20AND%20a:%RollingText%22)[中文版README](README_CN.md)
Features
========- easy to use, API is similar to TextView, and the setText method can be animated with up and down rolling
- support XML to set up common properties such as android:textSize/ android:textColor/ android:textStyle
- highly customizable to support animation effects of any single character
Animation
========### Strategy
Different rolling effects can be achieved by setting different animation strategies
> The default animation is to roll down when small characters change to large characters, and vice versa.
>
> You can also specify that rolling to the same direction
>
> The carry animation can be worked from low digit to high digit, not only for decimal. But it can only be used for strings with a length less than 10 to prevent integer from overflow. It can only be used for a sequence of characters containing 0, otherwise the calculation of the carry will be meaningless.![StrategyCompare][2]
### The order of characters
- The sequence of characters needs to be set up to tell ``RollingTextView`` how to change from the original character to the target character
- The common sequence of characters can be found in the ``CharOrder`` constant class
- When multiple orders are added and all are applicable to the target character and the original character, the precedence of the previous setting will be higher```java
alphaBetView.addCharOrder(CharOrder.Alphabet);
alphaBetView.addCharOrder(CharOrder.UpperAlphabet);
alphaBetView.addCharOrder(CharOrder.Number);
alphaBetView.addCharOrder(CharOrder.Hex);
alphaBetView.addCharOrder(CharOrder.Binary);
```![charOrderCompare][3]
### Rolling fluency
> The fluency of the animation can be adjusted by passing a ``factor`` parameter. The closer the ``factor`` value is to 0, the rolling will appear to be more hopping. And the closer the ``factor`` value is to 1, the more smooth the rolling is.
![stickyFactor][4]
### other
More ideas can be implemented on the ``CharOrderStrategy`` interface to customize your own animation effects
Download
========```groovy
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}dependencies {
implementation "com.github.YvesCheung.RollingText:RollingText:x.y.z"
}
```
> x.y.z replace with [![](https://jitpack.io/v/YvesCheung/RollingText.svg)](https://jitpack.io/#YvesCheung/RollingText)Usage
=========### XML settings
```xml
```
### write in java code
```java
final RollingTextView rollingTextView = findViewById(R.id.alphaBetView);
rollingTextView.setAnimationDuration(2000L);
rollingTextView.setCharStrategy(Strategy.NormalAnimation);
rollingTextView.addCharOrder(CharOrder.Alphabet);
rollingTextView.setAnimationInterpolator(new AccelerateDecelerateInterpolator());
rollingTextView.addAnimatorListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
//finsih
}
});
rollingTextView.setText("i am a text");
```Debug
========Using [Uinspector](https://github.com/YvesCheung/UInspector), You can debug the properties of `RollingTextView`:
![debug preview](https://raw.githubusercontent.com/YvesCheung/RollingText/master/rollingtextviewinspector/debug.gif)
Add `Uinspector` to your `build.gradle`:
```groovy
dependencies {
// debugImplementation because Inspector should only run in debug builds.
debugImplementation "com.github.YvesCheung.RollingText:RollingTextInspector:x.y.z"
}
```License
========Copyright 2018 Yves Cheung
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 athttp://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.[1]: https://raw.githubusercontent.com/YvesCheung/RollingText/master/ezgif.com-optimize.gif
[2]: https://raw.githubusercontent.com/YvesCheung/RollingText/master/StrategyCompare.gif
[3]: https://raw.githubusercontent.com/YvesCheung/RollingText/master/charOrderCompare.gif
[4]: https://raw.githubusercontent.com/YvesCheung/RollingText/master/stickyFactor.gif