- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在我的 View 类中使用 SVG 文件,我遇到的问题是:当我像这样设置 VectorDrawable 的色调时:
var d = AppCompatResources.getDrawable(context, R.drawable.icon)
var vDraw = VectorDrawable()
vDraw = d as VectorDrawable
DrawableCompat.setTint(vDraw , Color.RED)
vDraw.draw(canvas)
我最终要修改原始可绘制对象。有没有一种方法可以在不修改原始 SVG 的情况下在代码中执行此操作?
最佳答案
您需要调用 drawable mutate()
方法。来自documentation :
Make this drawable mutable. This operation cannot be reversed. A mutable drawable is guaranteed to not share its state with any other drawable. This is especially useful when you need to modify properties of drawables loaded from resources. By default, all drawables instances loaded from the same resource share a common state; if you modify the state of one instance, all the other instances will receive the same modification. Calling this method on a mutable Drawable will have no effect.
因为你想给你的drawable着色,你还需要使用DrawableCompat.wrap(drawable)
。这将允许:
Potentially wrap {@code drawable} so that it may be used for tinting across the different API levels, via the tinting methods in this class.
将此应用于您的代码:
var drawable = AppCompatResources.getDrawable(context, R.drawable.icon)
drawable = drawable.mutate();
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable , Color.RED)
drawable.draw(canvas)
关于android - 如何在不修改原始可绘制对象的情况下设置 vectorDrawable 的色调?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53117470/
我想将一些颜色值从众所周知的 HSL 转换为鲜为人知的 HSLum 怎么做? hsl(0, 1.0, 0.5) - rgb red is hslum(0, 1.0., 0.54) hsl(120,
在 xml 中为 ImageView 设置色调时,我收到一条警告,显示:- 必须使用 app:tint 而不是 android:tint 为什么我应该使用 app:tint? 最佳答案 因为有一些问题
如果我有一个 alpha 整数和三个用于色调、饱和度和亮度的 float ,我如何使用一种方法以最紧凑的方式将它们转换为一个 argb 值? 编辑:我知道我可以使用 HSBtoRGB,我已经通读了 j
尝试在 firemonkey 中实现类似于此的环形颜色选择器:http://dph.am/iDropper/ 我认为可以使用在笔划上具有多点渐变的 TCircle 来完成。根据我的实验和研究,渐变只能
我在 Hadoop 2.6.2 集群中使用 Hue 3.9。这些计算机都有 Ubuntu 14.04。我能够成功安装 Hue,但从 Web UI 查看 hue 时确实出现了一些错误。我试图一次解决这些
有没有一种方法可以使用 jQ 或某些插件对图像进行着色(应用色调)?谢谢 最佳答案 我能想到的最简单的方法是在图像上覆盖一个半透明的 div。 一个小例子: HTML CSS .overlay
类似于this previous question ,我想将任意颜色的色调应用于任意图像(UIImageView)。然而,我希望色调在 N 秒的时间内逐渐消失,以产生“脉冲”效果。我将每 M 秒触发一
是否有任何命令来检查Hadoop中当前正在运行多少个色调 session ,以及是否有任何方法可以查看已随着年龄运行的 session ? 最佳答案 一个可以帮助解决这个问题的吉拉是HUE-2288
我是 seaborn 的新手,我有这个数据集,想创建一个这样的图表,但要使用 seaborn。 这是我的数据: max_depth = [ 3, 3, 3, 3, 3, 5, 5, 5,
我是 seaborn 的新手,我有这个数据集,想创建一个这样的图表,但要使用 seaborn。 这是我的数据: max_depth = [ 3, 3, 3, 3, 3, 5, 5, 5,
如何使用 Stylus 更改十六进制颜色值的色调和增加饱和度? 最佳答案 Stylus 实际上内置了这些功能。基于文档 hue , saturation : 以下应该有效: 色调(#00c, 90de
我正在尝试创建一个应用程序,允许我通过调整上述每个字段的搜索栏来调整图像的色调、饱和度、亮度、对比度和清晰度。喜欢 http://ronbigelow.com/articles/workflow_ba
我为此问题创建了一个示例数据集 import pandas as pd from pandas import DataFrame import seaborn as sns import numpy
(HI) 我不是比色学方面的专家,但我想知道如何实现基于主色生成随机颜色的脚本。 可能是随机的阴影或色调 例如:#f25f9a。 http://www.color-hex.com/color/f25f
我用 TextView 制作了一些复选框和单选按钮,但它们在 Lollipop 之前没有着色。 我的 TextView 扩展 AppCompatCheckedTextView,样式如下: ?
我创建了一个启用了分析的 Solr 仪表板。计数器按钮现在显示,但它是灰色的。 Hue 或 solr 中是否有任何我应该启用的附加标志? 谢谢 我正在使用 Solr 7 + Hue 4 最佳答案 这是
正如标题所说,如何将状态栏图标的颜色更改为深色调而不是默认的白色。 来自 到 最佳答案 要使状态栏图标具有深色而不是默认的白色,请在 styles.xml 中添加以下标记(或者更准确地说是在 valu
刚刚在我的 iPhone 3GS 上切换到 iOS 4,我的一些应用程序崩溃了。 我遇到的一个问题是,我有一个带有一些按钮的 UIToolbar,颜色为粉红色,在 3.1.3 操作系统上运行良好。升级
我有一个“位图”类型,其中包含一些随机位图数据。我已经编写了自己的亮度、颜色、饱和度和色调调整,这些调整分别作用于每个位,毫不奇怪,速度非常慢。 在我的研究中,我注意到使用矩阵可以非常快地调整这些。此
假 --> HEX color:
我是一名优秀的程序员,十分优秀!