您的位置:首页 > 移动开发 > Android开发

Android 圆角进度条RoundCornerProgressBar

2016-10-17 12:20 447 查看

转自:http://www.jcodecraeer.com/a/opensource/2015/0115/2313.html


介绍:

圆角矩形进度条,包含带图标和不带图标两种形式


运行效果:




使用说明:

布局文件中添加roundcornerprogressbar控件

<com.akexorcist.roundcornerprogressbar.RoundCornerProgressBar
android:layout_width="dimension"
android:layout_height="dimension"
app:backgroundPadding="dimension"
app:backgroundRadius="dimension"
app:backgroundColor="color"
app:progressColor="color"
app:progress="integer"
app:max="integer" />
属性说明:



添加iconroundcornerprogressbar

<com.akexorcist.roundcornerprogressbar.IconRoundCornerProgressBar
android:layout_width="dimension"
android:layout_height="dimension"
app:iconPadding="dimension"
app:iconSize="dimension"
app:iconSrc="drawable"
app:backgroundPadding="dimension"
app:backgroundRadius="dimension"
app:backgroundColor="color"
app:headerColor="color"
app:progressColor="col
4000
or"
app:progress="integer"
app:max="integer" />
属性说明:



RoundCornerProgressBar的公共方法:

void setProgressColor(int color)
int getProgressColor()
void setBackgroundColor(int color)
int getBackgroundColor()

void setMax(float max)
int getMax()
void setProgress(float progress)
int getProgress()
IconRoundCornerProgressBar的公共方法:

void setProgressColor(int color)
int getProgressColor()
void setBackgroundColor(int color)
int getBackgroundColor()
void setHeaderColor(int color)
int getHeaderColor()

void setMax(float max)
int getMax()
void setProgress(float progress)
int getProgress()

void setIconImageResource(int resource)
void setIconImageBitmap(Bitmap bitmap)
void setIconImageDrawable(Drawable drawable)
例子:

xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent" >

<com.akexorcist.roundcornerprogressbar.RoundCornerProgressBar
android:id="@+id/progress_1"
android:layout_height="320dp"
android:layout_width="40dp"
app:backgroundPadding="5dp" />

<com.akexorcist.roundcornerprogressbar.IconRoundCornerProgressBar
android:id="@+id/progress_2"
android:layout_height="320dp"
android:layout_width="wrap_content"
app:backgroundPadding="10dp"
app:iconSize="50dp"
app:iconPadding="5dp" />

</RelativeLayout>
java代码

RoundCornerProgressBar progress1 = (RoundCornerProgressBar) findViewById(R.id.progress_1);
progress1.setProgressColor(Color.parseColor("#ed3b27"));
progress1.setBackgroundColor(Color.parseColor("#808080"));
progress1.setMax(70);
progress1.setProgress(15);

int progressColor1 = progress1.getProgressColor();
int backgroundColor1 = progress1.getBackgroundColor();
int max1 = progress1.etMax();
int progress1 = progress1.getProgress();

RoundCornerProgressBar progress2 = (RoundCornerProgressBar) findViewById(R.id.progress_1);
progress2.setProgressColor(Color.parseColor("#56d2c2"));
progress2.setBackgroundColor(Color.parseColor("#757575"));
progress2.setHeaderColor(Color.parseColor("#38c0ae"));
progress2.setMax(550);
progress2.setProgress(147);
progress2.setIconImageResource(anyResource);
progress2.setIconImageBitmap(anyBitmap);
progress2.setIconImageDrawable(anyDrawable);

int progressColor2 = progress2.getProgressColor();
int backgroundColor2 = progress2.getBackgroundColor();
int headerColor2 = progress2.getHeaderColor();
int max2 = progress2.getMax();
int progress2 = progress2.getProgress();

源码下载
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: