Android倒计时控件 CountdownView

中文

CountdownView

Android countdown view,use canvas draw,supports multiple styles

Download demo apk

Screenshot

 

 

 

Gradle

compile 'com.github.iwgang:countdownview:2.1.6'

Code

CountdownView mCvCountdownView = (CountdownView)findViewById(R.id.cv_countdownViewTest1);
mCvCountdownView.start(995550000); // Millisecond

// or
for (int time=0; time<1000; time++) {
    mCvCountdownView.updateShow(time);
}

Layout

<cn.iwgang.countdownview.CountdownView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:isHideTimeBackground="true"
    app:isShowDay="true"
    app:isShowHour="true"
    app:isShowMinute="true"
    app:isShowSecond="true"
    app:isShowMillisecond="true"
    app:timeTextColor="#000000"
    app:timeTextSize="22sp"
    app:isTimeTextBold="true"
    app:suffixGravity="bottom"
    app:suffixTextColor="#000000"
    app:suffixTextSize="12sp"
    app:suffixHour="时"
    app:suffixMinute="分"
    app:suffixSecond="秒"
    app:suffixMillisecond="毫秒" />

Customization

attrtypedefault
isHideTimeBackgroundbooleantrue
timeBgColorcolor#444444
timeBgSizedimensiontimeSize + 2dp * 4
timeBgRadiusdimension0
isShowTimeBgDivisionLinebooleantrue
timeBgDivisionLineColorcolor#30FFFFFF
timeBgDivisionLineSizedimension0.5dp
timeTextSizedimension12sp
timeTextColorcolor#000000
isTimeTextBoldbooleanfalse
isShowDaybooleanauto show (has value show if not hide)
isShowHourbooleanauto show (has value show if not hide)
isShowMinutebooleantrue
isShowSecondbooleantrue
isShowMillisecondbooleanfalse
isConvertDaysToHoursbooleanfalse
suffixTextSizedimension12sp
suffixTextColorcolor#000000
isSuffixTextBoldbooleanfalse
suffixGravity'top' or 'center' or 'bottom''center'
suffixstring':'
suffixDaystringnull
suffixHourstringnull
suffixMinutestringnull
suffixSecondstringnull
suffixMillisecondstringnull
suffixLRMargindimensionleft 3dp right 3dp
suffixDayLeftMargindimension0
suffixDayRightMargindimension0
suffixHourLeftMargindimension0
suffixHourRightMargindimension0
suffixMinuteLeftMargindimension0
suffixMinuteRightMargindimension0
suffixSecondLeftMargindimension0
suffixSecondRightMargindimension0
suffixMillisecondLeftMargindimension0
isShowTimeBgBorderbooleanfalse
timeBgBorderColorcolor#000000
timeBgBorderSizedimension1dp
timeBgBorderRadiusdimension0

Other

  • Multiple countdownView specified value
    // step 1
    mCvCountdownView.setTag(R.id.name, uid);
    // step 2
    @Override
    public void onEnd(CountdownView cv) {
        Object nameTag = cv.getTag(R.id.uid);
        if (null != nameTag) {
            Log.i(TAG, "name = " + nameTag.toString());
        }
    }
  • Dynamic show
    dynamicShow(DynamicConfig dynamicConfig)
  • Countdown complete callback
    setOnCountdownEndListener(OnCountdownEndListener onCountdownEndListener);
  • Interval callback
    setOnCountdownIntervalListener(long interval, OnCountdownIntervalListener onCountdownIntervalListener);
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值