基于第三方的倒计时控件
2016-04-11 22:56
183 查看
1、加依赖
compile 'com.github.iwgang:countdownview:1.2'
2、在xml中使用控件
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.bruce.time.MainActivity"> <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:isShowMillisecond="true" app:isShowMinute="true" app:isShowSecond="true" app:isTimeTextBold="true" app:suffixDay="天" app:suffixGravity="bottom" app:suffixHour="时" app:suffixMillisecond="毫秒" app:suffixMinute="分" app:suffixSecond="秒" app:suffixTextColor="#000000" app:suffixTextSize="12sp" app:timeTextColor="#000000" app:timeTextSize="22sp"/> </RelativeLayout>3、java代码中设置
package com.bruce.time; import android.app.Activity; import android.os.Bundle; import cn.iwgang.countdownview.CountdownView; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initWidget(); } private void initWidget() { CountdownView mCvCountdownView = (CountdownView) findViewById(R.id.cv_countdownViewTest1); //倒计时1分钟-60秒*1000=60000millisecond mCvCountdownView.start(60000); // Millisecond // or for (int time = 0; time < 1000; time++) { mCvCountdownView.updateShow(time); } } }第三方原地址:
https://github.com/iwgang/CountdownView
相关文章推荐
- Material Design support
- css实现居中的五中方法
- linux中socket的理解---4
- LeetCode(46)-Remove Nth Node From End of List
- week3-1
- 嵌入式Linux下Camera编程--V4L2 ---fwqlzz love is for ever
- 第1章 c#简介
- LeetCode(46)-Remove Nth Node From End of List
- LeetCode(46)-Remove Nth Node From End of List
- jQuery $(document).ready()和JavaScript onload事件
- 多窗体
- Vmware Redhat 6.3 静态IP、DNS、网关配置
- MySQL 常用命令
- leetcode 295. Find Median from Data Stream
- 338. Counting Bits
- NSArray、NSMutableArray基本用法
- 求最高分(华为简单面试题)
- 【华为机试题】将输入字符串中的大写字符改为小写,标点符号空格等删除
- 函数响应式编程(FRP)框架--ReactiveCocoa
- Android---Adapter