Seekbar or progress bar with multiple colors

后端 未结 4 1771
孤街浪徒
孤街浪徒 2020-12-13 08:02

\"enter

I want to create a bar like this initially when progress is zero it will be a

4条回答
  •  北海茫月
    2020-12-13 08:20

    You can't actually set the progress bars to different colors. You can however use only the on drawable and get the effect that you want. You could just apply a layer mask. What I mean is add a Relative layout which is initially say dark grey throughout i.e the gradient has only ONE color which is dark gray. Now, use code to set the gradient color on the left programmatically. Obviously the color on the left is going to be transparent. Learn more about Linear Gradients. That's about it. You just need to calculate the position from where the right gradient starts, rather where the left gradient(transparent)ends.

    This method is slightly flawed and may not work on ALL devices.

    The flawless method would be to create multiple .9png images and set the drawable of the progress dialog programmatically every time.

提交回复
热议问题