Android 如何在矢量可绘制图像中添加圆形边框?

Android 如何在矢量可绘制图像中添加圆形边框?,android,xml,android-vectordrawable,Android,Xml,Android Vectordrawable,我有一张眼睛的矢量可绘制图像,我想要圆形的边框,但我找不到任何解决方案 我对形象的要求如下: 我正在为眼睛图标使用xml代码,如下所示: 您可以将圆作为图像视图的背景,并将其src设置为矢量 <ImageView android:layout_width="48dp" android:layout_height="48dp" android:src="@drawable/eye" android:

我有一张眼睛的矢量可绘制图像,我想要圆形的边框,但我找不到任何解决方案

我对形象的要求如下:

我正在为眼睛图标使用xml代码,如下所示:


您可以将圆作为图像视图的背景,并将其src设置为矢量

<ImageView
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:src="@drawable/eye"
    android:tint="#747474"
    android:background="@drawable/circle_gray"
    android:padding="6dp"/>

在可绘图文件夹中圈出\u gray.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <stroke android:width="2dp"
        android:color="#747474"/>

</shape>

根据要求改变宽度和高度。最好在colors.xml中使用颜色

结果:-


您可以修改您的
SVG

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="125dp"
    android:height="125dp"
    android:viewportWidth="125"
    android:viewportHeight="125">
  <path
      android:pathData="M48.7,11.5c-12,3.3 -24.1,12.2 -30.8,22.6 -13.8,21.5 -10.9,49.1 7,66.9 21.7,21.6 54.5,21.6 76.2,-0 29,-28.8 15.4,-79 -24.2,-89.5 -6.6,-1.8 -21.7,-1.8 -28.2,-0zM73.2,13.1c8.9,1.8 19,7.3 25.5,13.8 10.1,10.1 15.3,22.5 15.3,36.6 0,14.7 -5.2,26.7 -15.9,36.8 -7.6,7.1 -15.3,11.2 -24.9,13.3 -8.4,1.7 -12,1.7 -20.4,-0 -9.6,-2.1 -17.3,-6.2 -24.9,-13.3 -10.7,-10.1 -15.9,-22.1 -15.9,-36.8 0,-32.4 29.8,-56.9 61.2,-50.4z"
      android:fillColor="#000000"
      android:strokeColor="#00000000"/>
  <path
      android:pathData="M51.8,41.5c-5.5,2.1 -11.6,6.5 -20.5,14.9l-7.8,7.5 3.3,0.1c3.7,-0 8.1,-2 18,-8.4 8.1,-5.2 12,-6.6 18.2,-6.6 6.2,-0 10.1,1.4 18.2,6.6 10,6.4 14.3,8.4 18,8.4 3.3,-0.1 3.3,-0.1 -6.2,-9.1 -12.4,-11.7 -17.6,-14.3 -29,-14.6 -5.4,-0.2 -9.8,0.3 -12.2,1.2z"
      android:fillColor="#000000"
      android:strokeColor="#00000000"/>
  <path
      android:pathData="M57.4,57.9c-6,3.7 -6.6,12.1 -1.2,16.6 4,3.4 9.6,3.4 13.6,-0 3.8,-3.2 4.8,-6.3 1.8,-5.8 -3.2,0.7 -7.6,-3.3 -7.6,-6.7 0,-1.6 0.5,-3.2 1,-3.5 1.9,-1.2 1,-2.5 -1.7,-2.5 -1.6,-0 -4.2,0.9 -5.9,1.9z"
      android:fillColor="#000000"
      android:strokeColor="#00000000"/>
  <path
      android:pathData="M37.5,63.1c-3.3,1.6 -7.2,2.9 -8.7,2.9 -1.6,-0 -2.8,0.4 -2.8,1 0,2.5 10.6,11.2 18.7,15.2 8.4,4.2 8.9,4.3 18.3,4.3 9.4,-0 9.9,-0.1 18.3,-4.3 8.1,-4 18.7,-12.6 18.7,-15.1 0,-0.6 -1.3,-1.1 -2.9,-1.1 -1.5,-0 -5.5,-1.3 -8.7,-3 -3.2,-1.6 -6,-3 -6.1,-3 -0.1,-0 0.2,1.2 0.8,2.7 2.4,6.5 -2.2,15.3 -10.2,19.4 -5.2,2.6 -14.6,2.6 -19.8,-0.1 -7.5,-3.8 -12.1,-12.2 -10.2,-18.8 0.5,-1.8 0.9,-3.2 0.8,-3.1 -0.1,-0 -2.9,1.4 -6.2,3z"
      android:fillColor="#000000"
      android:strokeColor="#00000000"/>
</vector>

你的行动会


您可以用这种方法制作圆形边框,

圆形边框的向量,

最后在layerlist的第二项中使用您的眼睛图像。会很好的。
看起来是这样的,

@harshpatel您可以接受这个答案。点击勾号符号我只是想知道我如何才能学会这一点来创造自己的他人。?