Giter Club home page Giter Club logo

countdownview's Introduction

CountDownView

广告倒计时控件。

简介

一款简单易用的广告倒计时控件。

下载

第一步:添加 JitPack 仓库到你项目根目录的 gradle 文件中。
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
第二步:添加这个依赖。
dependencies {
    compile 'com.github.kelinZhou:CountDownView:1.0.0'
}

效果图

CountDownView

使用

xml布局文件中使用。

<com.kelin.countdownview.CountDownView
    android:id="@+id/cd_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:duration="5000" <!--指定倒计时时长。默认为5000毫秒。-->
    android:text="跳过广告"<!--指定文本内容。默认为"跳过"。-->
    app:lineTextLength="2"<!--指定单行文字的长度,没有指定的话如果文本内容小于两位则默认为文本长度,否则为文本长度的一半。-->
    android:textSize="14sp"<!--指定字体大小。默认为14sp。-->
    android:textColor="#FFF"<!--指定字体颜色,默认为白色。-->
    app:progressBarWidth="2dp"<!--指定进度条宽度,默认为2dp。-->
    app:progressBarColor="#f0f4"<!--指定进度条颜色,默认为红色:#FF00-->
    app:progressBarMode="clockwiseFromExist"/><!--指定进度条模式,可以为:clockwiseFromNothing(顺时针从无到有)、clockwiseFromExist(顺时针从有到无)、anticlockwiseFromNothing(逆时针从无到有)、anticlockwiseFromExist(逆时针从有到无)-->

以上属性都可以在代码中设置,只是必须在start()方法调用前调用。

代码中使用。

//找到倒计时控件设置监听并启动倒计时。
((CountDownView)findViewById(R.id.cd_view)).setOnFinishListener(new CountDownView.OnFinishListener() {
            @Override
            public void onFinish() {
                Toast.makeText(getApplicationContext(), "倒计时完毕!", Toast.LENGTH_SHORT).show();
            }
        }).start();

代码就是这样了,你只需要监听onFinish就可以了,点击事件不需要监听。如果你非要监听点击事件也不要在onClick(View view)事件中做结束倒计时的操作,因为我已经处理好了,无论你是否监听了点击事件在View被点击后都会执行oFinish(),而且CountDownView本身也没有提供结束倒计时的方法。


License

Copyright 2016 [email protected]

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.

countdownview's People

Contributors

kelinzhou avatar

Stargazers

WSonglin avatar Devin avatar 行一 avatar  avatar  avatar

Watchers

James Cloos avatar  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.