Reputation: 2882
I have successfully changed the color of my progress bar to the colors available in Color (blue, green etc.), but when I give the hexcode of a particular color I get a bar with nothing in it. How can I resolve this?
ProgressBar pg = (ProgressBar)findViewById(R.id.progressBarDownload);
final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
ShapeDrawable progressDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null,null));
progressDrawable.getPaint().setColor(0x01060012);//<-----problem here?
ClipDrawable progress = new ClipDrawable(progressDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
pg.setProgressDrawable(progress);
pg.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));
pg.setProgress(40);
Upvotes: 0
Views: 484
Reputation: 856
try like this"
Drawable progressDrawablePause = MainActivity.this.getResources().getDrawable(R.drawable.download_progressbar_pause_bg);
progressDrawablePause.setBounds(bar.getProgressDrawable().getBounds());
bar.setProgressDrawable(progressDrawablePause);
bar.setProgress(60);
first: set the drawable bounds second: set the progressdrawable third:setprogress
Upvotes: 0
Reputation: 2721
Try like this..
ProgressBar pg = (ProgressBar)row.findViewById(R.id.progress);
final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
pgDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null,null));
String MyColor = "#FF00FF";
pgDrawable.getPaint().setColor(Color.parseColor(MyColor));
ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
pg.setProgressDrawable(progress);
pg.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));
pg.setProgress(45);
import this
import android.graphics.drawable.*;
Upvotes: 0
Reputation: 2732
Try to use RGB values instead of hex color code, you can easily find the RGB values of the hex color code using ColorPic or any other similar tool.
Upvotes: 1
Reputation: 3261
Use this code its works for me
String source = "<b><font color=#ff0000> Loading. Please wait..."
+ "</font></b>";
pd = ProgressDialog.show(Main.this, "",
Html.fromHtml(source), true);
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
Upvotes: 1