Android 圆角进度条RoundCornerProgressBar

转自: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" />
属性说明:

usage_002.jpg

添加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="color"
        app:progress="integer"
        app:max="integer" />
属性说明:

usage_001.jpg


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();

源码下载


猜你喜欢

转载自blog.csdn.net/liuwan1992/article/details/52837734
今日推荐