Android自定義View StateProgressView 物流/購(gòu)物流程等進(jìn)度展示

效果圖

Github地址https://github.com/liuhaizhu/StateProgressView-master

實(shí)現(xiàn)流程
  • 繪制一個(gè)從左到由逐漸填充的圓環(huán)
  • 繪制一個(gè)從左到由逐漸變色的直線 ,可設(shè)置圓角
  • 繼承FrameLayout,根據(jù)傳入的數(shù)據(jù)(幾個(gè)節(jié)點(diǎn))結(jié)合設(shè)置的數(shù)據(jù),確定共有幾個(gè)圓環(huán)和直線,然后計(jì)算并設(shè)置這些子View的大小和位置,如果文字,計(jì)算文字位置和顯示文字的TextView大小
  • 然后開(kāi)始執(zhí)行動(dòng)畫,每個(gè)節(jié)點(diǎn)的動(dòng)畫繪制完成都會(huì)有一個(gè)回調(diào)動(dòng)作通知下一個(gè)節(jié)點(diǎn)執(zhí)行動(dòng)畫
How to use

Gradle Dependency

compile 'com.lhz:StateProgressView:1.0.1'
Attributes

Declare it inside your layout XML file like this:

<com.lhz.stateprogress.StateProgressView 
   android:id="@+id/spv"
   android:layout_height="wrap_content"
   android:layout_width="match_parent"   
   app:color_circle_fill="#d81e06"   
   app:color_circle_stroke="#d81e06"  
   app:line_height="8dp"   
   app:is_line_radius="true" 
   app:radius_circle_fill="12dp"  
   app:radius_circle_stroke="16dp"
   app:state_height="48dp"   
   app:color_text_normal="#bfbfbf"   
   app:color_line_state="#d81e06"    
   app:color_line_normal="#dbdbdb"   
 />
Set value and Perform the animation
final StateProgressView spv= (StateProgressView) findViewById(R.id.spv);
//下方帶文字 設(shè)置節(jié)點(diǎn)集合 最后節(jié)點(diǎn)的index為4 直接執(zhí)行動(dòng)畫 list是String 類型的 index要小于list的數(shù)量
spv.setItems(list, 4, 200);
//下方帶文字 設(shè)置節(jié)點(diǎn)集合
spv.setItems(list);
//最后節(jié)點(diǎn)的index為2 每個(gè)節(jié)點(diǎn)動(dòng)畫時(shí)長(zhǎng)為1000毫秒
spv.startAnim(2,1000);
//下方不帶文字 設(shè)置共有四個(gè)節(jié)點(diǎn) 最后節(jié)點(diǎn)的index為2 每個(gè)節(jié)點(diǎn)動(dòng)畫時(shí)長(zhǎng)為1000毫秒
spv.setItems(4);
spv.startAnim(2,1000);
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容