移动|CountdownView秒杀倒计时

直接在 github 搜索CountdownView
//地址:这里就直接查看中文了:-- https://github.com/iwgang/CountdownView/blob/master/README_CN.md
/* 定时器依赖 */ compile 'com.github.iwgang:countdownview:2.1.6'
Activity:代码: public class MainActivity extends AppCompatActivity {
@Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout. activity_main ); CountdownView mCvCountdownViewTest1 = (CountdownView)findViewById(R.id. cv_countdownViewTest1 ); mCvCountdownViewTest1.setTag( "test1" ); // 倒计 5 小时 1000 为 1S long time1 = ( long ) 5 * 60 * 60 * 1000 ; // 开启倒计时 mCvCountdownViewTest1.start(time1); } }
activiti_main.xml 引用自定义的背景需添加 xmlns: app = "http://schemas.android.com/apk/res-auto" < LinearLayout android :layout_width= "match_parent" android :layout_height= "wrap_content" android :orientation= "vertical" >
< cn.iwgang.countdownview.CountdownView android :id= "@+id/cv_countdownViewTest1" android :layout_width= "wrap_content" android :layout_height= "wrap_content" android :layout_gravity= "center_horizontal" android :layout_marginTop= "20dp" app :isHideTimeBackground= "false" app :isShowDay= "false" app :isShowHour= "true" app :isShowMillisecond= "false" app :isShowMinute= "true" app :isShowSecond= "true" app :isShowTimeBgDivisionLine= "false" app :suffixGravity= "center" app :suffixTextColor= "#000000" app :suffixTextSize= "20sp" app :timeBgColor= "#FF5000" app :timeTextColor= "#FFFFFF" app :timeTextSize= "20sp" />

新建一个xml,放到drawble文件下
布局:自定义背景的布局 < selector xmlns: android = "http://schemas.android.com/apk/res/android" >
< item android :state_pressed= "true" > < shape android :shape= "rectangle" > < corners android :radius= "3dp" /> < solid android :color= "#ffff8f2f" /> < stroke android :color= "#000000" android :width= "0.5dp" />
< item > < shape android :shape= "rectangle" > < corners android :radius= "3dp" /> < solid android :color= "#ffffb62f" /> < stroke android :color= "#000000" android :width= "0.5dp" /> 移动|CountdownView秒杀倒计时
文章图片

    推荐阅读