package com.zzcyi.airpurifier.view;
import android.content.context;
import android.graphics.canvas;
import android.graphics.color;
import android.graphics.paint;
import android.graphics.rect;
import android.os.systemclock;
import android.util.attributeset;
import android.view.view;
/** * 自定義絢麗的progressbar.
*/public class progressbarview extends view
public progressbarview(context context, attributeset attrs)
public progressbarview(context context, attributeset attrs, int defstyleattr)
private void init()
@override
protected void onmeasure(int widthmeasurespec, int heightmeasurespec)
}private rect textbounds = new rect();
@override
protected void ondraw(canvas canvas)
}if (sweep1>arc_full_degree * (35 / max) && sweep1<=arc_full_degree * (75 / max))else if ( drawdegree>arc_full_degree * (50 / max) && drawdegree<=arc_full_degree * (100 / max))
}if (sweep1>arc_full_degree * (75 / max) && sweep1<=arc_full_degree * (115 / max))else if ( drawdegree>arc_full_degree * (50 / max) && drawdegree<=arc_full_degree * (100 / max))else if (drawdegree>arc_full_degree * (100 / max) && drawdegree<=arc_full_degree * (150 / max))
}if (sweep1>arc_full_degree * (115 / max) && sweep1<=arc_full_degree * (200 / max))else if ( drawdegree>arc_full_degree * (35 / max) && drawdegree<=arc_full_degree * (75 / max))else if (drawdegree>arc_full_degree * (75 / max) && drawdegree<=arc_full_degree * (115 / max))else if (drawdegree>arc_full_degree * (115 / max) && drawdegree<=arc_full_degree * (200 / max))
}if (sweep1>arc_full_degree * (200 / max) && sweep1<=arc_full_degree * (300 / max))else if ( drawdegree>arc_full_degree * (35 / max) && drawdegree<=arc_full_degree * (75 / max))else if (drawdegree>arc_full_degree * (75 / max) && drawdegree<=arc_full_degree * (115 / max))else if (drawdegree>arc_full_degree * (115 / max) && drawdegree<=arc_full_degree * (200 / max))else if (drawdegree>arc_full_degree * (200 / max) && drawdegree<=arc_full_degree * (300 / max))
}if (sweep1>arc_full_degree * (300 / max) )else if ( drawdegree>arc_full_degree * (35 / max) && drawdegree<=arc_full_degree * (75 / max))else if (drawdegree>arc_full_degree * (75 / max) && drawdegree<=arc_full_degree * (115 / max))else if (drawdegree>arc_full_degree * (115 / max) && drawdegree<=arc_full_degree * (200 / max))else if (drawdegree>arc_full_degree * (200 / max) && drawdegree<=arc_full_degree * (300 / max))else if (drawdegree>arc_full_degree * (200 / max) )
}if (drawdegree > sweep1)
canvas.drawline(linestartx, linestarty, linestopx, linestopy, progresspaint);
drawdegree += arc_each_progress;
}//上一行文字
textpaint.settextsize(circleradius >> 1);
string text = (int)progress + "";
float textlen = textpaint.measuretext(text);
//計算文字高度
textpaint.gettextbounds("8", 0, 1, textbounds);
float h1 = textbounds.height();
canvas.drawtext(text, centerx - textlen / 2, centery - circleradius / 10 + h1 / 2, textpaint);
//下一行文字
textpaint.settextsize(circleradius / 5);
text = pmtext(progress);
textlen = textpaint.measuretext(text);
canvas.drawtext(text, centerx - textlen / 2, centery + circleradius / 2.5f, textpaint);
}protected string pmtext(float pmint) else if (35 < pmint && pmint <= 75) else if (75 < pmint && pmint <= 115) else if (115 < pmint)else
}public void setmax(int max, int progress)
//動畫切換進度值(非同步)
public void setprogress(final float progress)
}}).start();
}//直接設定進度值(同步)
public void setprogresssync(float progress)
/*** 計算漸變效果中間的某個顏色值。
* 僅支援 #aarrggbb 模式,例如 #ccc9c9b2
*/public string calcolor(float fraction, string startvalue, string endvalue)
//從原始#aarrggbb顏色值中指定位置擷取,並轉為int.
private int getintvalue(string hexvalue, int start, int end)
private string gethexstring(int value)
return a;
}}
空氣淨化器哪個牌子好 室內空氣淨化的最好方法
室外的空氣我們管不到,但是對室內的空氣我們還是有辦法解決的,這主要你是看大家有沒有決心,想不想要安全的室內空氣。因為解決室內空氣不好的辦法有很多,速度最快效果最好的就是使用空氣淨化器,這也是空氣淨化器的最主要的作用。我相信室內的空氣汙染很多人是有了解的,比如甲醛 細菌病毒 有害氣體等多是需要解決的,...
空氣淨化器哪個牌子好?高智慧型的空氣淨化器
冰尊空氣淨化器榮獲空氣質素淨化的十大品牌的冠軍!從陌生到熟悉,空氣淨化器已然隨著空氣汙染的日漸嚴重走進了我們的生活。空氣淨化器在市面www.cppcns.com上隨處可見,種類和款式也非常多,很多朋友家裡都有空氣淨化器。那麼你知道空氣淨化器哪個牌子好嗎?下面是國際空氣質素協會評選的十大品牌 空氣淨化...
空氣淨化器的新思路 將植物養在機器裡
在人與自然的相處過程中,空氣淨化器是連線二者關係走向和諧的重要紐帶。但在目前的空氣淨化器市場上,不同種類和品牌的空氣淨化器產品雖然名目繁多,但它們除了品牌名稱有差別之外,大多空氣淨化器產品在原理 構造和淨化效果方面均近乎驚人的一致。比如最常見的空氣淨化器產品中,大多品牌智慧型針對室內空氣進行過濾處理...