Android開源: StateProgressView - 物流進度

wgif7353 7年前發布 | 12K 次閱讀 安卓開發 Android開發 移動開發

效果圖

實現流程

  • 繪制一個從左到由逐漸填充的圓環
  • 繪制一個從左到由逐漸變色的直線 ,可設置圓角
  • 繼承FrameLayout,根據傳入的數據(幾個節點)結合設置的數據,確定共有幾個圓環和直線,然后計算并設置這些子View的大小和位置,如果文字,計算文字位置和顯示文字的TextView大小
  • 然后開始執行動畫,每個節點的動畫繪制完成都會有一個回調動作通知下一個節點執行動畫

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);
//下方帶文字 設置節點集合 最后節點的index為4 直接執行動畫 list是String 類型的 index要小于list的數量
spv.setItems(list, 4, 200);
//下方帶文字 設置節點集合
spv.setItems(list);
//最后節點的index為2 每個節點動畫時長為1000毫秒
spv.startAnim(2,1000);
//下方不帶文字 設置共有四個節點 最后節點的index為2 每個節點動畫時長為1000毫秒
spv.setItems(4);
spv.startAnim(2,1000);

 

來自:http://www.jianshu.com/p/28d7ffd9eda4

 

 本文由用戶 wgif7353 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!