EasyRollingNumber

by newcaoguo

newcaoguo /EasyRollingNumber

🍎轻松实现滚动数字效果

133 Stars 22 Forks Last release: over 2 years ago (1.0) Apache License 2.0 15 Commits 1 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

1. EasyRollingNumber项目介绍

🍎

EasyRollingNumber
项目是一个用来轻松实现滚动数字效果的库。

2. 效果展示

演示图

3. 使用方法:

第一步: 在你的根目录中的 build.gradle 文件中,repositories 标签下添加一下代码:

Add it in your root build.gradle at the end of repositories:

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

第二步: 添加依赖 Add the dependency

    dependencies {
            implementation 'com.github.newcaoguo:EasyRollingNumber:1.0'
    }

4. 使用示例

1) 在布局文件中添加如下代码,与一般控件相同

java

2) 在 Activity 中声明 自定义控件的变量
java
    // 显示金钱的自定义控件
    private ScrollingDigitalAnimation money;    
    // 显示数字的自定义控件
    private ScrollingDigitalAnimation number;  
    // 显示百分比的自定义控件
    private ScrollingDigitalAnimation percentage; 
3) 初始化控件
java
        money = findViewById(R.id.text);
        number = findViewById(R.id.text1);
        percentage = findViewById(R.id.text2);

4) 设置一个响应事件,并在方法里面配置相关属性

java
    /**
     * 启动按钮单击事件
     * @author newcaoguo
     */
    public void start(View view) {
        money.setPrefixString("¥");//设置符号
        money.setNumberString("9", "9999999999");//设置起始于结束的数字
        money.setDuration(3000);
        number.setNumberString("1234567890");
        number.setDuration(4000);
        percentage.setPostfixString("%");
        percentage.setNumberString("0.99", "99.99");
        percentage.setDuration(5000);
    }

5. API 说明

| API 名称 | 含 义 | 默 认 值 | | -------- | -----: | :----: | | setPrefixString(String prefixString) | 设置前缀字符串 | 空 | | setPostfixString(String postfixString) | 设置后缀字符串 | 空 | | setDuration(long duration) | 设置动画持续时间 | 2000 ms |

License

Copyright 2018 newcaoguo

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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.