在布局中
創(chuàng)新互聯(lián)專(zhuān)注于燈塔企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,商城網(wǎng)站定制開(kāi)發(fā)。燈塔網(wǎng)站建設(shè)公司,為燈塔等地區(qū)提供建站服務(wù)。全流程定制網(wǎng)站,專(zhuān)業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)專(zhuān)業(yè)和態(tài)度為您提供的服務(wù)
//也可以設(shè)置布局中的attr屬性
使用方法
//設(shè)置類(lèi)型
pb_1.setProgressType(ProgressBarUtils.ProgressType.COUNT);
//設(shè)置圓形的填充顏色
pb_1.setInCircleColor(getResources().getColor(R.color.redTab));
//設(shè)置外部輪廓的顏色
pb_1.setOutLineColor(getResources().getColor(R.color.grayLine));
//設(shè)置進(jìn)度監(jiān)聽(tīng)
pb_1.setCountdownProgressListener(1, progressListener);
//設(shè)置外部輪廓的顏色
pb_1.setOutLineWidth(2);
//設(shè)置進(jìn)度條線的寬度
pb_1.setProgressLineWidth(5);
//設(shè)置進(jìn)度
pb_1.setProgress(60);
//設(shè)置倒計(jì)時(shí)總時(shí)間
pb_1.setTimeMillis(3000);
//設(shè)置進(jìn)度條顏色
pb_1.setProgressColor(getResources().getColor(R.color.colorPrimary));
//開(kāi)始
pb_1.start();
//暫停
pb_1.stop();
//重新開(kāi)始
pb_1.reStart();
在布局中
代碼調(diào)用
bar1 = (NumberProgressbar) findViewById(R.id.bar1);
//設(shè)置倒計(jì)時(shí)總時(shí)間
bar1.setTimeMillis(10000);
//設(shè)置最大進(jìn)度條的值
bar1.setMax(100);
//設(shè)置進(jìn)度條文本的顏色
bar1.setProgressTextColor(this.getResources().getColor(R.color.colorAccent));
//設(shè)置進(jìn)度條文本的大小
bar1.setProgressTextSize(ProgressBarUtils.sp2px(this,14));
//設(shè)置百分比文字內(nèi)容是否可見(jiàn)
bar1.setNumberTextVisibility(ProgressBarUtils.NumberTextVisibility.Visible);
//設(shè)置百分比進(jìn)度條的高度
bar1.setReachedBarHeight(10);
//設(shè)置未更新百分比進(jìn)度條的高度
bar1.setUnreachedBarHeight(10);
//設(shè)置百分比進(jìn)度條的顏色
bar1.setReachedBarColor(this.getResources().getColor(R.color.redTab));
//設(shè)置未更新百分比進(jìn)度條的顏色
bar1.setUnreachedBarColor(this.getResources().getColor(R.color.blackText2));
//設(shè)置百分比進(jìn)度條的監(jiān)聽(tīng)
bar1.setOnProgressBarListener(new OnNumberProgressListener() {
@Override
public void onProgressChange(int current, int max) {
}
});
//開(kāi)始
bar1.start();
//暫停
bar1.stop();
bar_percent = (RingProgressBar) findViewById(R.id.bar_percent);
//設(shè)置進(jìn)度
bar_percent.setProgress(0);
//設(shè)置更新進(jìn)度條顏色
bar_percent.setDotColor(this.getResources().getColor(R.color.colorAccent));
//設(shè)置未更新部分的進(jìn)度條顏色
bar_percent.setDotBgColor(this.getResources().getColor(R.color.blackText));
//設(shè)置百分比文字顏色
bar_percent.setPercentTextColor(this.getResources().getColor(R.color.blackText1));
//設(shè)置百分比文字大小
bar_percent.setPercentTextSize(ProgressBarUtils.dp2px(this,16.0f));
//設(shè)置展示的類(lèi)型
bar_percent.setShowMode(ProgressBarUtils.RingShowMode.SHOW_MODE_PERCENT);
//設(shè)置單位的文字內(nèi)容
bar_percent.setUnitText("%");
//設(shè)置單位的文字大小
bar_percent.setUnitTextSize(ProgressBarUtils.dp2px(this,16.0f));
//設(shè)置單位的文字顏色
bar_percent.setUnitTextColor(this.getResources().getColor(R.color.blackText1));
/**
* 驗(yàn)證進(jìn)度。
*
* @param progress 你要驗(yàn)證的進(jìn)度值。
* @return 返回真正的進(jìn)度值。
*/
private int validateProgress(int progress) {
if (progress > 100){
progress = 100;
} else if (progress < 0){
progress = 0;
}
return progress;
}
/**
* 當(dāng)自定義控件銷(xiāo)毀時(shí),則調(diào)用該方法
*/
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
stop();
}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.