前言#
最近群里有人說他們?cè)陧?xiàng)目中有實(shí)現(xiàn)圓形進(jìn)度的需求,但是對(duì)于自定義View的技能比較弱史隆。
后來我索性直接做成一個(gè)庫(kù),直接一句代碼即可使用compile'com.wanlili:circleprogressview:1.0.1'
一句話#
一個(gè)簡(jiǎn)約純粹的圓形進(jìn)度條。(API>=19)
上gif#
使用#
你只需要傳入你想要的參數(shù)即可驯耻。例如
如果你想要一些自定義的樣式(有以下三個(gè)自定義屬性)
<com.wanli.com.circleprogressview.CircleProgressView
android:id="@+id/circle"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
app:c_colorCircle="@color/colorPrimary" //圓形的顏色
app:c_colorProgress="@color/colorAccent" //進(jìn)度的顏色
app:c_strokeWidth="20.0" /> //圓形的寬度
如果你想在啟動(dòng)之前設(shè)置一些默認(rèn)值
circle = (CircleProgressView) findViewById(R.id.circle);
circle.setDurationsecondscurrent(1f); //設(shè)置當(dāng)前進(jìn)度
circle.setDurationSecondsMax(10f); //設(shè)置最大進(jìn)度
circle.setTotalSeconds(1000); //設(shè)置一共需要耗時(shí)多少毫秒。不設(shè)置默認(rèn)從1到10為每隔一秒加1
啟動(dòng)
circle.start(); //啟動(dòng)
如果你還想在啟動(dòng)后實(shí)時(shí)得到進(jìn)度的數(shù)值炒考,那么你啟動(dòng)的時(shí)候傳一個(gè)接口回調(diào)參數(shù)即可
circle.start(new CircleProgressView.OnProgressListener() {
@Override
public void onProgressListener(float progress) { //實(shí)時(shí)進(jìn)度的數(shù)值
text1.setText(String.valueOf(progress));
}
@Override
public void onProgressEnd(float progress) { //結(jié)束的數(shù)值
text1.setText(String.valueOf(progress));
}
});
也許你想在其它地方得到進(jìn)度數(shù)值
circle.getDurationsecondscurrent()
暫停可缚,恢復(fù),判斷是否結(jié)束呢
circle.pause();
circle.resume();
circle.isEnd()
也許你還想看看源碼斋枢,或者直接來個(gè)例子
https://github.com/WanLiLi/CircleProgressView 記得Star
也許你還好奇上一篇講了什么帘靡?
http://www.reibang.com/p/f160b787231e Android折疊伸縮效果的實(shí)現(xiàn)
基于上一篇的文章中的gif,有一個(gè)好眼力的簡(jiǎn)友[Android里的海賊王]就詢問從A跳轉(zhuǎn)到B界面中的圖片動(dòng)畫是怎么實(shí)現(xiàn)的瓤帚,多個(gè)元素一起執(zhí)行動(dòng)畫又怎么實(shí)現(xiàn)描姚。關(guān)于這個(gè)問題,不知道有多少人需要了解戈次?
結(jié)束#
感謝打賞過以及關(guān)注的簡(jiǎn)友轩勘,是你們讓我在心情不好的時(shí)候還能堅(jiān)持寫作。