我已经成功地将进度条的颜色更改为color中可用的颜色(蓝色、绿色等),但是当我给出特定颜色的十六进制码时,我得到一个没有任何内容的条。我该如何解决这个问题?
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);发布于 2013-01-18 14:38:44
试着这样..。
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);导入此文件
导入android.raphics.Drawable.*;
发布于 2013-01-18 14:23:10
使用这段代码,它对我很有效
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);发布于 2013-01-18 14:26:09
尝试使用RGB值而不是十六进制颜色代码,您可以使用ColorPic或任何其他类似工具轻松找到十六进制颜色代码的RGB值。
https://stackoverflow.com/questions/14393415
复制相似问题