How to put a vector in a shape in Android

0 votes

I'm trying to make customizable icons in Android. I made the vector element, but now I want to give it a rounded background, so I tried to place it within a rounded shape. Like this:

<?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>

Yet this doesn't work, and I'm trying to achieve the following:
enter image description here

By using only the vector I don't get the background.
(I used this website to generate the vector)


 

Dec 8, 2022 in Android by Edureka
• 11,450 points
50 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Android

0 votes
0 answers

How to put a border around an Android TextView?

Is it possible to draw a border ...READ MORE

Nov 23, 2022 in Android by Ashwini
• 2,960 points
136 views
0 votes
0 answers

How to make grid view scroll horizontally not vertically in android?

I use a flexible Grid View. means ...READ MORE

Sep 21, 2022 in Android by Edureka
• 12,890 points
78 views
0 votes
1 answer

How to turn on front flash light programmatically in Android?

For this problem you should: Check whether the ...READ MORE

answered Nov 8, 2022 in Android by Edureka
• 11,450 points
198 views
0 votes
1 answer

How to display Toast in Android?

Use the show() function of the Toast ...READ MORE

answered Nov 8, 2022 in Android by Edureka
• 11,450 points
203 views
0 votes
1 answer
0 votes
1 answer

How to set my Activity as main activity in android?

The "intent-filter" in "AndroidManifest.xml" allows you to ...READ MORE

answered Nov 8, 2022 in Android by Edureka
• 12,890 points
86 views
0 votes
0 answers

How to define a circle shape in an Android XML drawable file?

I'm having some trouble locating the Android ...READ MORE

Nov 22, 2022 in Android by Edureka
• 11,450 points
296 views
0 votes
1 answer

How to make Diamond shape xml background for android view

you can do this: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> ...READ MORE

answered Jun 1, 2022 in Others by nisha
• 2,190 points
802 views
0 votes
0 answers

How to make gradient background in android

As in the example below, I want ...READ MORE

Nov 24, 2022 in Android by Tejashwini
• 3,470 points
66 views
0 votes
1 answer

Appending values to a vector - R

This is actually quite easy, all you ...READ MORE

answered May 15, 2018 in Data Analytics by Bharani
• 4,660 points
256 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP