Home

Awesome

Android Gems Android Arsenal @iwgang

中文

CountdownView

Android countdown view,use canvas draw,supports multiple styles

Download demo apk

Screenshot

<img src="https://raw.githubusercontent.com/iwgang/CountdownView/master/screenshot/s_main.png" width="400px" height="650px"/>

<img src="https://raw.githubusercontent.com/iwgang/CountdownView/master/screenshot/s_list.jpg" width="400px" height="650px"/>

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

    // 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());
        }
    }
    dynamicShow(DynamicConfig dynamicConfig)
    setOnCountdownEndListener(OnCountdownEndListener onCountdownEndListener);
    setOnCountdownIntervalListener(long interval, OnCountdownIntervalListener onCountdownIntervalListener);