GithubHelp home page GithubHelp logo

huyanghu / easyrollingnumber Goto Github PK

View Code? Open in Web Editor NEW

This project forked from newcaoguo/easyrollingnumber

0.0 2.0 0.0 508 KB

🍎轻松实现滚动数字效果

License: Apache License 2.0

Java 100.00%

easyrollingnumber's Introduction

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. 在布局文件中添加如下代码,与一般控件相同
<com.newcaoguo.easyrollingnumber.view.ScrollingDigitalAnimation
        android:id="@+id/text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="52dp"
        android:textSize="28sp" />
  1. 在 Activity 中声明 自定义控件的变量
    // 显示金钱的自定义控件
    private ScrollingDigitalAnimation money;    
    // 显示数字的自定义控件
    private ScrollingDigitalAnimation number;  
    // 显示百分比的自定义控件
    private ScrollingDigitalAnimation percentage; 
  1. 初始化控件
        money = findViewById(R.id.text);
        number = findViewById(R.id.text1);
        percentage = findViewById(R.id.text2);
  1. 设置一个响应事件,并在方法里面配置相关属性
    /**
     * 启动按钮单击事件
     * @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.

easyrollingnumber's People

Contributors

newcaoguo avatar

Watchers

James Cloos avatar xiongxiaolong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.