Has*_*ssa 2 android kotlin android-jetpack-compose
好的,我已经创建了自己的 .SVG 矢量图标并将其作为 XML 导入 Android Studio。现在我正在尝试使用相同的向量创建一个图标。但是,当我在 PainterResource() 中指定该向量时,它会将其绘制为黑色。而我原来的 SVG 有多种颜色。为什么会发生这种情况?
Icon(
painter = painterResource(id = R.drawable.ic_google_logo),
contentDescription = "Google Button"
)
Run Code Online (Sandbox Code Playgroud)
Ste*_*ack 17
老实说,我认为接受的答案不是正确的做法。图标自动着色为必要的上下文颜色。
如果您想显示不着色的图标,我建议使用图像:
Image(
painter = painterResource(id = R.drawable.ic_google_logo),
contentDescription = "Google Button"
)
Run Code Online (Sandbox Code Playgroud)
该Icon应用默认的色彩(LocalContentColor.current.copy(alpha = LocalContentAlpha.current))
使用tint= Color.Unspecified以避免它:
Icon(
painter = painterResource(id = R.drawable.ic_google_logo),
contentDescription = "Google Button",
tint= Color.Unspecified
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
82 次 |
| 最近记录: |