LayerDrawable drawable = (LayerDrawable) mItemProgressbar.getProgressDrawable();
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setColor(Color.parseColor("接口返回的颜色值"));
ClipDrawable clipDrawable = new ClipDrawable(gradientDrawable,Gravity.START,ClipDrawable.HORIZONTAL);
drawable.setDrawableByLayerId(android.R.id.progress,clipDrawable);
只需要将setColor()方法中的参数换成你自己想要的色值就OK了
网友评论