填充颜​​色的位图的android [英] Fill color on bitmap in android

查看:106
本文介绍了填充颜​​色的位图的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能填充颜色图像(即燃料图像)在特定区域按搜索栏的进步。

How i can fill color on image(i.e fuel image) in specific area as per Seek bar progress.

我曾尝试以下解决方案,但它是没有帮助的多少按我的要求。

i have tried following solution but it is not helpful much as per my requirement.

请看看下面的图片了解更多的参考。

please find below image for more reference.

推荐答案

您也可以绘制位图上有层的顶部。 简单地用相同的尺寸栏添加一个位图(或者任何你有)要具有彩色的,然后添加颜色,并说在多大程度上应该在酒吧的颜色。

You could also draw a bitmap on top of the layer you have. Simply add a bitmap with the same dimensions as the bar (or whatever you have) you want to have coloured in. Then add the colours and say how far it should colour in the bar.

例如:

// making our bitmap and canvas
        Bitmap bmResult = Bitmap.createBitmap(barWidth, 75,
                Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bmResult);
        paint.setShader(new LinearGradient(widthToFill, 75, widthToFill, 75,
                0xFF97ca3e, 0xFF284060, TileMode.MIRROR));
        paint.setShader(new LinearGradient(widthToFill, 75, widthToFill, 75,
                0xFF97ca3e, 0xFF284060, TileMode.CLAMP));
        paint.setARGB(188, 164, 120, 130);
        canvas.drawRect(0, 0, widthToFill, 75, paint);

widthToFill会与你要多少以绘制值的变量,你也可以得出这样的动力通过获取屏幕宽度和计算的百分比。

widthToFill would be a variable with the value of how much you want to draw in. You could also draw this dynamic by getting the screenwidth and calculating the percentages.

祝您好运。

这篇关于填充颜​​色的位图的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆