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

源碼下載


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章