SimpleCountDownView icon indicating copy to clipboard operation
SimpleCountDownView copied to clipboard

A simple countdown view with translation animation ...

SimpleCountDownView

A simple countdown view with translation animation.

If you have any questions,let me know ~ ~ ~ ~ [email protected]

Results show

image

Usage

You can just copy my java code CountDownView into your project.

Add this to your xml file :

 <com.example.countdownview.CountDownView
       android:id="@+id/count_down_time"
       android:layout_width="@dimen/count_down_w"
       android:layout_height="@dimen/count_down_h"
       android:layout_centerHorizontal="true"/>

Just call fowlling methods to set countdownview :

  1. set the time when to start and end.
countDownView.setTime(NumFrom, NumTo);
  1. add listener to CountDownView.
 countDownView.setOnTimeListener(new CountDownView.OnTimeListener() {
            @Override
            public void onTimeStart() {
               //count down start
            }

            @Override
            public void onTimeEnd() {
                //count down end
            }
        });
  1. you can choose four different direction.
countDownView.setAnimationStyle(CountDownView.FROM_TOP);

countDownView.setAnimationStyle(CountDownView.FROM_BOTTOM);

countDownView.setAnimationStyle(CountDownView.FROM_LEFT);

countDownView.setAnimationStyle(CountDownView.FROM_RIGHT);
  1. you can also change other attribute by yourself , for example :
//View Size : the height of view must be as same as the tranlation offset. 

android:layout_height="@dimen/count_down_h"

offset = getResources().getDimension(R.dimen.count_down_h);
//keep TIME_TRANS+TIME_STAY = 1000
private static int TIME_TRANS = 300; //number scroll duration
private static int TIME_STAY = 700;  //number stay duration