如何在Android中的<shape>中放置<vector>?

Edw*_*ard 17 android vector shape android-drawable

我正在尝试在Android中制作可自定义的图标.我制作了矢量元素,但现在我想给它一个圆形背景,所以我试着把它放在一个圆形的形状中.像这样:

<?xml version="1.0" encoding="utf-8"?>
<!-- drawable/circle_card_icon.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:height="24dp"
        android:width="24dp"
        android:viewportWidth="24"
        android:viewportHeight="24">
        <path android:fillColor="#000"
            android:pathData="M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4A2,2 0 0,0 20,2M6,9H18V11H6M14,14H6V12H14M18,8H6V6H18" />
    </vector>
</shape>
Run Code Online (Sandbox Code Playgroud)

然而,这不起作用,我正在努力实现以下目标:
在此输入图像描述

通过仅使用矢量我不会得到背景.
(我用这个网站生成矢量)

Fan*_*mas 39

我没有将矢量放入形状,而是使用LayerList Drawable

像这样的东西:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <!-- drawable/circle_card_icon.xml -->
        <shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="oval">
            <solid android:color="#8df"/>
            <size 
                android:width="48dp"
                android:height="48dp"
            />
        </shape>
    </item>
    <item android:drawable="@drawable/your_vector_drawable" />
</layer-list>
Run Code Online (Sandbox Code Playgroud)