代码更换SeekBar进度条颜色

来源:互联网 发布:php的框架有哪些 编辑:程序博客网 时间:2024/06/05 06:23
           Drawable vipDrawable1 = context.getResources().getDrawable(R.drawable.bg_seek2_vip);
            vipDrawable1.setBounds(seekBar.getProgressDrawable().getBounds());//要设置之前的bounds不然会显示不出新的进度条颜色

            seekBar.setProgressDrawable(vipDrawable1);

            seekBar.setThumb(context.getResources().getDrawable(R.drawable.portrait_bg_thumb2));
            seekBar.invalidate();


对于 seekBar.setThumb这个一定要设置,即使在xml中设置了也要在写一遍。


我之前没有这句话,进度条的宽度竟然和滑块一样高,即使在xml中设置了setmaxheight和setminheight,也是会没有效果,使得进度条太粗。


seekbar属性中有setMinimumHeight但是没有相应的setmaxheiht这个挺纠结的,所以seekBar.setThumb这个一定要设置。


阅读全文
0 0
原创粉丝点击