I want to change the seekbar progress color and background color at runtime with code not with xml. I know how to do it with xml (Layerlist-Shapedrawable-Clipdrawable)
I can't change the colors in my colors.xml
so I have to set the progress drawable by code. I already tried different things with LayerDrawable etc... but didn't get anything to work. Any ideas?
public void setProgressBarColor(ProgressBar progressBar, int newColor){
LayerDrawable ld = (LayerDrawable) progressBar.getProgressDrawable();
ClipDrawable d1 = (ClipDrawable) ld.findDrawableByLayerId(R.id.progressshape);
d1.setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
}
When you update the progress, you will see the result.
Is it ok?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.