[英]How to change the color of element in SVG Image in Android
此图像是 Android Studio 的屏幕截图,它是一个带圆形边框的灰色矩形,加号是透明的。 这是以下文件 xml:
<vector android:autoMirrored="true" android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#e8e8e8"
android:pathData="M19,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM17,13h-4v4h-2v-4L7,13v-2h4L11,7h2v4h4v2z"/>
</vector>
我想将矩形内元素“plus”的颜色从透明更改为黑色,我该怎么做?
我发现解决方案如下:
我只是下载 plus svg 图像,然后创建一个矩形,如下所示
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#e8e8e8" />
<corners android:radius="10dp" />
</shape>
我就是这样用的
android:background="@drawable/rectangle_shape"
app:srcCompat="@drawable/ic_add"
要改变纯色,android:fillColor 用于改变纯色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.