本文介绍了自定义进度配多色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用的要求是定制progressbar.A定制进展哪个具有多色Indication.For例子进展示出绿颜色.Progress小于60小于30,并示出与黄色大于30,最后进展60〜100所示与红色。

My Application requirement is custom progressbar.A Custom Progress Which have Multicolor Indication.For example Progress Smaller than 30 shown with Green Color .Progress Smaller than 60 and Greater than 30 shown with yellow color and finally the Progress From 60 to 100 Shown with Red Color .

我想作这样的进度条

我是新android开发。

I am new to android development.

在此先感谢

推荐答案

延长搜索栏类并覆盖其的OnDraw()方法。有,但是你想,你可以画拇指和进步的背景。

Extend the Seekbar class and override its onDraw() method. There you can draw the thumb and progress background however you want.


创建进度绘制静态背景(更容易比计划绘制),并加入到资源。您可以将此作为XML或自定义类的构造函数的进步绘制。


Create a drawable progress background statically (easier than drawing in program.) and add to resources. You can set this as progress drawable in xml or in your custom class constructor.

class MySeekbar extends Seekbar {

    // In Constructor load the thumb image into static members.

    // override onDraw draw the thumb.
    void onDraw(Canvas canvas) {
         canvas.save();
         canvas.drawBitmap(mThumb, left, top, right, bottom);
         canvas.restore();
    }
}

这篇关于自定义进度配多色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 04:55