Skip to content

mahdi-khosravi-sh/numberview

Repository files navigation

NumberView

Peek 2021-09-27 19-44

GitHub repo size GitHub language count GitHub top language GitHub last commit

A beautiful widget for displaying numbers with animation

Table of Contents
  1. Getting Started
  2. Stats
  3. Contributing
  4. License
  5. Contact

Getting Started

Download

Download the latest AAR from jitpack via Gradle:

  • Gradle

    Project build.gradle

    allprojects {
      repositories {
        ...
        maven { url 'https://jitpack.io' }
      }
    }

    app module build.gradle

    dependencies {
      implementation 'com.github.mahdidev78:numberview:TAG'
    }
  • Maven

    Add the JitPack repository to your build file

    <repositories>
      <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
      </repository>
    </repositories>

    Add the dependency

    <dependency>
      <groupId>com.github.mahdidev78</groupId>
      <artifactId>numberview</artifactId>
      <version>Tag</version>
    </dependency>

Usage

Step 1

Add the NumberView to your layout :

<com.mahdikh.vision.numberview.widget.NumberView
  android:id="@+id/numberView"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textColor="#000000"
  android:textSize="45sp"
  app:animator="@string/DefaultAnimator"
  app:duration="300"
  app:interpolator="@android:interpolator/accelerate_decelerate"
  app:number="10" />

Step 2

Setup your code :

  • Kotlin
    val numberView:NumberView = findViewById(R.id.numberView)
    numberView.setOnClickListener {
      numberView.increment()
    }
  • Java
    NumberView numberView = findViewById(R.id.numberView);
    numberView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            numberView.increment();
        }
    });

Advanced Step 3

  • kotlin
    numberView.animator = SlideAnimator().apply {
        setDuration(450)
        setInterpolator(FastOutSlowInInterpolator())
        gravity = Gravity.END
    }
  • Java
    SlideAnimator animator = new SlideAnimator(Gravity.END);
    animator.setDuration(450);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    numberView.setAnimator(animator);

Animators

DefaultAnimator, SlideAnimator, FadeAnimator, ScaleAnimator, RotationAnimator , FlipAnimator

Attributes

attribute Description Options(examples)
number The desired number to set as text 20,486, ...
animator animator class name FadeAnimator,ScaleAnimator, etc
duration animator duration 500, 600, etc
interpolator animator interpolator @android:interpolator/overshoot

Stats

Contributors Forks Stargazers Issues Apache License

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the Apache2.0 License. See LICENSE for more information.

Contact

Mahdi Khosravi - mahdi.khosravi.dev78@gmail.com

Project Link: https://github.com/mahdidev78/numberview