您好,登錄后才能下訂單哦!
在布局中
//也可以設(shè)置布局中的attr屬性
<com.ns.yc.ycprogresslib.CircleProgressbar
android:id="@+id/pb_1"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="進(jìn)度條" />
使用方法
//設(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();
在布局中
<com.ns.yc.ycprogresslib.NumberProgressbar
android:id="@+id/bar1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.ns.yc.ycprogresslib.NumberProgressbar
android:id="@+id/bar2"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:progress_max="100"
app:progress_reached_bar_height="3dp"
app:progress_unreached_bar_height="3dp"
app:progress_reached_color="@color/colorPrimary"
app:progress_unreached_color="@color/gray3"
app:progress_text_size="14sp"
app:progress_text_color="@color/colorAccent"
app:progress_text_visibility="visible"/>
代碼調(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();
<com.ns.yc.ycprogresslib.RingProgressBar
android:id="@+id/bar_percent"
android:layout_width="100dp"
android:layout_height="100dp"/>
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.
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。