how to change SeekBar color in android? (Programma

2020-07-08 02:49发布

I made an equalizer to go with my app but I am not sure how I can change the seekbar's thumb and progress color. It seems to be pink by default and that doesn't fit my app's aesthetics.

 SeekBar seekBar = new SeekBar(this);

        seekBar.setId(i);

        seekBar.setLayoutParams(layoutParams);
        seekBar.setMax(upperEqualizerBandLevel - lowerEqualizerBandLevel);

        seekBar.setProgress(mEqualizer.getBandLevel(equalizerBandIndex));
        //seekBar.setBackgroundColor(Color.DKGRAY);
        //seekBar.setDrawingCacheBackgroundColor(Color.DKGRAY);

8条回答
贪生不怕死
2楼-- · 2020-07-08 03:14

try this :

seekBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.mcolor), PorterDuff.Mode.MULTIPLY);
查看更多
萌系小妹纸
3楼-- · 2020-07-08 03:17

You need to call you seekbar like this

SeekBar newSeek = new SeekBar(this, null, R.style.YOUR_NEW_STYLE);

where YOUR_NEW_STYLE will define the colors of the Seekbar that you want.

查看更多
登录 后发表回答