Android Countdown View

Overview

Android Gems Android Arsenal @iwgang

中文

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

attr type default
isHideTimeBackground boolean true
timeBgColor color #444444
timeBgSize dimension timeSize + 2dp * 4
timeBgRadius dimension 0
isShowTimeBgDivisionLine boolean true
timeBgDivisionLineColor color #30FFFFFF
timeBgDivisionLineSize dimension 0.5dp
timeTextSize dimension 12sp
timeTextColor color #000000
isTimeTextBold boolean false
isShowDay boolean auto show (has value show if not hide)
isShowHour boolean auto show (has value show if not hide)
isShowMinute boolean true
isShowSecond boolean true
isShowMillisecond boolean false
isConvertDaysToHours boolean false
suffixTextSize dimension 12sp
suffixTextColor color #000000
isSuffixTextBold boolean false
suffixGravity 'top' or 'center' or 'bottom' 'center'
suffix string ':'
suffixDay string null
suffixHour string null
suffixMinute string null
suffixSecond string null
suffixMillisecond string null
suffixLRMargin dimension left 3dp right 3dp
suffixDayLeftMargin dimension 0
suffixDayRightMargin dimension 0
suffixHourLeftMargin dimension 0
suffixHourRightMargin dimension 0
suffixMinuteLeftMargin dimension 0
suffixMinuteRightMargin dimension 0
suffixSecondLeftMargin dimension 0
suffixSecondRightMargin dimension 0
suffixMillisecondLeftMargin dimension 0
isShowTimeBgBorder boolean false
timeBgBorderColor color #000000
timeBgBorderSize dimension 1dp
timeBgBorderRadius dimension 0

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);
Comments
  • 有点问题需要请教

    有点问题需要请教

    您好作者,在RecyclerView中使用倒计时的时候,上下滑动 倒计时会暂停 ,多滑动几次就,变成0了,下拉刷新 时间又重置了,怎么解决这个问题啊 ,我Adapter继承的是BaseQuickAdapter com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.15这个里面的BaseAdapter

    opened by ljackChen001 7
  • About Handler

    About Handler

    Since this Handler is declared as an inner class, it may prevent the outer class from being garbage collected. If the Handler is using a Looper or MessageQueue for a thread other than the main thread, then there is no issue. If the Handler is using the Looper or MessageQueue of the main thread, you need to fix your Handler declaration, as follows: Declare the Handler as a static class; In the outer class, instantiate a WeakReference to the outer class and pass this object to your Handler when you instantiate the Handler; Make all references to members of the outer class using the WeakReference object.

    opened by NicodeLee 5
  • countUp on orientation change

    countUp on orientation change

    hi thank before to awesome libraries i want to make app to count down but i will to count up when phone orientation change . like hourglass timed. can i do it with countdownVIew ? i not find that in documentation thanks for help

    opened by yudikarma 4
  • How to use Interval

    How to use Interval

    Hi, thanks for your great library. I want show some time in my application and i want when lasted 5s show me toast. For example : I want how 17s countTimer, when this timer receive to 5s show me toast "just 5s".

    how can i it? please help me

    invalid 
    opened by bahramnooraii 4
  • 为什么天数转成小时要依赖于实现隐藏控件背景?

    为什么天数转成小时要依赖于实现隐藏控件背景?

    class CountdownView extends View {
    
        public CountdownView(Context context, AttributeSet attrs, int defStyleAttr) {
    	super(context, attrs, defStyleAttr);
    	TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CountdownView);
    	isHideTimeBackground = ta.getBoolean(R.styleable.CountdownView_isHideTimeBackground, true);
    	mCountdown = isHideTimeBackground ? new BaseCountdown() : new BackgroundCountdown();
    	// 初始化属性
    	mCountdown.initStyleAttr(context,ta);
    	ta.recycle();
    	mCountdown.initialize();
        }
    }
    
    class BaseCountdown {
    
        public void initStyleAttr(Context context, TypedArray ta) {
    	...省略若干代码...
    	// 为什么天数转成小时要依赖于实现隐藏控件背景?
    	if (ta.getBoolean(R.styleable.CountdownView_isHideTimeBackground, true)) {
    		isConvertDaysToHours = ta.getBoolean(R.styleable.CountdownView_isConvertDaysToHours, false);
    	}
        }
    }
    
    opened by Love667767 3
  • DynamicConfig

    DynamicConfig

    DynamicConfig constructor is a private access , so I can't get a instance , I want to config DynamicShow , due to countDownView.dynamicShow() method need a DynamicConfig type parameter,can you update DynamicConfig constructor permission modifier is public ?

    opened by xinpengfei520 3
  • isShowTimeBgBorder无效,边框没显示

    isShowTimeBgBorder无效,边框没显示

                    <cn.iwgang.countdownview.CountdownView
                        android:id="@+id/countDown"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginTop="4dp"
                        app:isShowDay="true"
                        app:isShowHour="true"
                        app:isShowMinute="true"
                        app:isShowSecond="true"
                        app:isShowTimeBgBorder="true"
                        app:suffixDay="天"
                        app:suffixGravity="bottom"
                        app:suffixHour="时"
                        app:suffixMinute="分"
                        app:suffixSecond="秒"
                        app:suffixTextColor="#ff383838"
                        app:suffixTextSize="10sp"
                        app:timeBgBorderColor="#ff383838"
                        app:timeBgBorderRadius="2dp"
                        app:timeBgBorderSize="2dp"
                        app:timeTextColor="#ff383838"
                        app:timeTextSize="12sp" />
    

    版本 'com.github.iwgang:countdownview:2.1.6'

    opened by DanteAndroid 0
  • 为什么设置了isShowDay=

    为什么设置了isShowDay="true",天数小于0的时候,不隐藏"00天"呢?

    <cn.iwgang.countdownview.CountdownView android:id="@+id/cv_countdownViewTest1" 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:isTimeTextBold="true" app:suffixGravity="bottom" app:suffixDay="天" app:suffixHour="时" app:suffixMinute="分" app:suffixSecond="秒" app:suffixTextColor="#000000" app:suffixTextSize="12sp" app:timeTextColor="#000000" app:timeTextSize="22sp" />

    opened by roybill 1
Releases(2.1)
Owner
iWgang
To be continued...
iWgang
FloatingView can make the target view floating above the anchor view with cool animation

FloatingView FloatingView can make the target view floating above the anchor view with cool animation Links 中文版 README Blog about FloatingView demo.ap

UFreedom 1.8k Dec 27, 2022
用于做Path动画的自定义View。 I have a path.I have a view. (Oh~),Path(Anim)View.

PathAnimView 用于做Path动画的自定义View。 I have a path.I have a view. (Oh~),Path(Anim)View. 现已经找到图片->SVG->PATH的正确姿势, Now i have a pic.I have a view. Oh~,Path(A

张旭童 1.1k Oct 28, 2022
TourGuide is an Android library that aims to provide an easy way to add pointers with animations over a desired Android View

TourGuide TourGuide is an Android library. It lets you add pointer, overlay and tooltip easily, guiding users on how to use your app. Refer to the exa

Tan Jun Rong 2.6k Jan 5, 2023
View that imitates Ripple Effect on click which was introduced in Android L (for Android 2.3+)

RippleView View that imitates Ripple Effect on click which was introduced in Android L. Usage For a working implementation, Have a look at the Sample

Muthuramakrishnan Viswanathan 1.2k Dec 30, 2022
Snake View is a simple and animated linear chart for Android.

Snake View Snake library is a simple and animation line chart for Android. Latest Version How to use Configuring your project dependencies Add the lib

Txus Ballesteros 339 Dec 14, 2022
[] A simple way to "badge" any given Android view at runtime without having to cater for it in layout

Android ViewBadger A simple way to "badge" any given Android view at runtime without having to cater for it in layout. Note: If your aim is to replica

Jeff Gilfelt 3k Nov 28, 2022
Android view with both path from constructed path or from svg.

android-pathview You want to animate svg or normal Paths?<br> Change the color, pathWidth or add svg.<br> Animate the "procentage" property to make th

Georgi Eftimov 2.9k Dec 27, 2022
A horizontal view scroller library for Android

View Flow for Android ViewFlow is an Android UI widget providing a horizontally scrollable ViewGroup with items populated from an Adapter. Scroll down

Patrik Åkerfeldt 1.8k Dec 29, 2022
TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.

This project isn't maintained anymore. It is now recommended to use https://github.com/peterLaurence/MapView. MapView is maintained by Peter, one of o

Mike Dunn 1.5k Dec 29, 2022
A cool Open Source CoverFlow view for Android with several fancy effects.

FancyCoverFlow THIS PROJECT IS NO LONGER MAINTAINED! What is FancyCoverFlow? FancyCoverFlow is a flexible Android widget providing out of the box view

David Schreiber-Ranner 1.1k Nov 10, 2022
A simple, customizable and easy to use swipeable view stack for Android.

SwipeStack A simple, customizable and easy to use swipeable view stack for Android. QuickStart Include the Gradle dependency dependencies { compil

Frederik Schweiger 1.5k Dec 30, 2022
Custom android music player view.

InteractivePlayerView Custom android music player view. Screen Check it on youtube Usage(XML) Define it in your xml file. <co.mobiwise.library.Intera

Mert Şimşek 744 Dec 25, 2022
Shadow layout, shadow view for android.

ShadowViewHelper Shadow layout, shadow view for android. How to use: It's very simple to use. Gradle(Check newest version): compile 'com.github.wangji

WangJie 777 Dec 30, 2022
Android Quilt View Library

QuiltViewLibrary QuiltView displays views of different sizes in a scrollable grid. Dependencies This library depends on gridlayout_v7 ([email protected]:

Jacob Moncur 561 Nov 20, 2022
A velocimeter View for Android

Velocimeter A velocimeter View for Android Sample video: Youtube Velocimeter video Sample app: How to use Default colors <com.github.glomadrian.veloci

Adrián Lomas 614 Dec 4, 2022
Android-ScrollBarPanel allows to attach a View to a scroll indicator like it's done in Path 2.0

Path 2.0 like ScrollBarPanel for Android Android-ScrollBarPanel allows to attach a View to a scroll indicator like it's done in Path 2.0. Features Sup

Arnaud Vallat 551 Dec 22, 2022
Android library to create chat message view easily

ChatMessageView ChatMessageView helps you to create chat message view quickly like a typical chatting application. Its a container view, so you can ad

Himanshu Soni 641 Dec 24, 2022
A drawing view for your android application.

Android Draw A drawing view for your android application Download For information : checkout Sample App Code in repository. Dependency Step 1. Add the

Divyanshu Bhargava 409 Dec 30, 2022
Customizable Item Setting View Android

ItemSettingView Simple ItemSettingView and Custom Installation Add it in your root build.gradle at the end of repositories: allprojects { reposito

Andhika Yuana 15 Aug 19, 2022