繁体   English   中英

Android 矢量资产色调不变

[英]Android vector asset Tint not changing

我已经从 inte.net 下载了 SVG 格式的图标,我想像导航抽屉中的其他图标一样将其色调更改为黑色。 我附上了投诉问题图片和其他两个图标。 我的投诉图标的导航抽屉图片色调与其他图标不同。 我该如何改变它? https://i.stack.imgur.com/uDIvM.png

Complaint.xml

<vector 
 xmlns:tools="http://schemas.android.com/tools"
    android:height="25dp" android:viewportHeight="512"
    android:viewportWidth="512"
    android:width="25dp"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:tint="@color/black"
    tools:ignore="VectorRaster">
    <path android:fillColor="@color/white"
          android:pathData="M372.333,0H75.667C33.944,0 0,33.944
          0,75.667v172.666C0,290.056 33.944,324 75.667,324h3.282v46.051c0,
          4.045 2.437,7.691 6.173,9.238c1.237,0.513 2.537,0.762 3.825,
          0.762c2.603,0 5.16,-1.016 7.073,-2.929L149.143,324h37.395c5.522,
          0 10,-4.478 10,-10c0,-5.522 -4.478,-10 -10.001,-10H145c-2.652,0
         -5.195,1.054 -7.071,2.929L98.95,345.908V314c0,-5.522 -4.478,-10
         -10,-10H75.667C44.972,304 20,279.028 20,248.333V75.667C20,44.972
          44.972,20 75.667,20h296.666C403.028,20 428,44.972 428,75.667V162c0,
          5.522 4.478,10 10,10c5.522,0 10,-4.478 10,-10V75.667C448,33.944
          414.056,0 372.333,0z"
          tools:ignore="VectorRaster" />
          <path android:fillColor="@color/white"
          android:pathData="M258.916,238.099c-5.522,0 -10,4.478 -10,10v0.108c0,5.522 4.478,10 
          10,10c5.522,0 
          10,-4.478 10,-10v-0.108C268.916,242.576 264.438,238.099 258.916,238.099z"/>
          <path android:fillColor="@color/white" android:pathData="M512,287.79c0,-16.583 -12.765,-30.232 
          -28.983,-31.659c1.496,-3.684 2.328,-7.706 2.328,-11.921v-0.42c0,-17.529 -14.261,-31.79 
          -31.789,-31.79H314.088c-1.249,0 -2.488,0.234 -3.651,0.69l-16.369,6.42c-0.235,-5.314 
          -4.605,-9.554 -9.978,-9.554h-52c-5.522,0 -10,4.478 -10,10v176c0,5.522 4.478,10 10,10h52c3.028,0 
           5.736,-1.352 7.57,-3.479l87.948,106.298c1.882,2.273 4.672,3.601 7.623,3.625c0.027,0 0.055,0 0.082,0c2.921,0 5.698,-1.277 7.599,-3.499l3.812,-4.455c15.818,-18.487 19.308,-44.641 8.889,-66.627L393.674,408h59.882c17.528,0 31.789,-14.261 31.789,-31.79v-0.42c0,-4.215 -0.832,-8.237 -2.328,-11.921C499.235,362.442 512,348.793 512,332.21v-0.42c0,-8.428 -3.303,-16.095 -8.675,-21.79c5.372,-5.695 8.675,-13.362 8.675,-21.79V287.79zM274.09,376.088c-0.078,0.719 -0.079,1.446 0,2.168v7.3h-32v-156h32V376.088zM492,288.21c0,6.501 -5.289,11.79 -11.79,11.79h-66.788c-5.522,0 -10,4.478 -10,10c0,5.522 4.478,10 10,10h66.788c6.501,0 11.79,5.289 11.79,11.79v0.42c0,6.501 -5.289,11.79 -11.79,11.79h-66.788c-5.522,0 -10,4.478 -10,10c0,5.522 4.478,10 10,10h40.134c6.501,0 11.789,5.289 11.789,11.79v0.42c0,6.501 -5.288,11.79 -11.789,11.79H377.87c-3.428,0 -6.617,1.756 -8.45,4.653c-1.833,2.896 -2.055,6.53 -0.587,9.628l20.705,43.701c6.164,13.008 5.131,28.171 -2.387,40.135L294.09,373.639V240.584L315.979,232h137.577c6.501,0 11.789,5.289 11.789,11.79v0.42c0,6.501 -5.288,11.79 -11.789,11.79h-40.134c-5.522,0 -10,4.478 -10,10c0,5.522 4.478,10 10,10h40.134h26.654c6.501,0 11.79,5.289 11.79,11.79V288.21z"/>
    <path android:fillColor="@color/white" android:pathData="M372,152H76c-5.522,0 -10,4.478 -10,10c0,5.522 4.478,10 10,10h296c5.522,0 10,-4.478 10,-10C382,156.478 377.522,152 372,152z"/>
    <path android:fillColor="@color/white" android:pathData="M318.488,88H76c-5.522,0 -10,4.478 -10,10c0,5.522 4.478,10 10,10h242.488c5.522,0 10,-4.478 10,-10C328.488,92.478 324.01,88 318.488,88z"/>
    <path android:fillColor="@color/white" android:pathData="M379.069,90.93C377.21,89.069 374.63,88 372,88s-5.21,1.069 -7.07,2.93C363.07,92.791 362,95.37 362,98c0,2.64 1.069,5.21 2.93,7.069c1.86,1.86 4.44,2.931 7.07,2.931s5.21,-1.07 7.069,-2.931C380.93,103.21 382,100.63 382,98S380.93,92.79 379.069,90.93z"/>
    <path android:fillColor="@color/white" android:pathData="M186.537,216H76c-5.522,0 -10,4.478 -10,10c0,5.522 4.478,10 10,10h110.537c5.522,0 10,-4.478 10,-10C196.537,220.478 192.06,216 186.537,216z"/>
</vector>

您可以像这样以编程方式更改图像视图的颜色:

imageView.setColorFilter(ContextCompat.getColor(context,R.color.some_color));

最简单的方法是将 svg 文件中引用的每种颜色更改为android:fillColor & android:tint属性中所需的颜色

在您共享的 svg 中,您将黑色设置为android:tint ,将不同的颜色(白色)设置为android:fillColor 所以,用你想要的颜色制作它们

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM