简体   繁体   中英

Rounded corners for vector asset android studio

I am trying to get a .xml vector asset to have rounded corners. I have the following code that's a flag, but with straight corners, and for a better visual effect I would need the corners to be rounded. I have tried to add <corners..... /> inside the <path.. /> but there was no change

.xml:

<vector android:height="15dp" android:viewportHeight="15"
android:viewportWidth="21" android:width="21dp"
xmlns:aapt="http://schemas.android.com/aapt" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillType="evenOdd" android:pathData="M0,0h21v15h-21z"
    android:strokeColor="#00000000" android:strokeWidth="1">
    <aapt:attr name="android:fillColor">
        <gradient android:endX="10.5" android:endY="15"
            android:startX="10.5" android:startY="0" android:type="linear">
            <item android:color="#FFFFFFFF" android:offset="0"/>
            <item android:color="#FFF0F0F0" android:offset="1"/>
        </gradient>
    </aapt:attr>
</path>
<path android:fillType="evenOdd" android:pathData="M10,0h11v15h-11z"
    android:strokeColor="#00000000" android:strokeWidth="1">
    <aapt:attr name="android:fillColor">
        <gradient android:endX="15.5" android:endY="15"
            android:startX="15.5" android:startY="0" android:type="linear">
            <item android:color="#FFE5253D" android:offset="0"/>
            <item android:color="#FFCC162C" android:offset="1"/>
        </gradient>
    </aapt:attr>
</path>
<path android:fillType="evenOdd" android:pathData="M0,0h7v15h-7z"
    android:strokeColor="#00000000" android:strokeWidth="1">
    <aapt:attr name="android:fillColor">
        <gradient android:endX="3.5" android:endY="15"
            android:startX="3.5" android:startY="0" android:type="linear">
            <item android:color="#FF0A3D9C" android:offset="0"/>
            <item android:color="#FF042E7D" android:offset="1"/>
        </gradient>
    </aapt:attr>
</path>
<path android:fillType="evenOdd" android:pathData="M7,0h7v15h-7z"
    android:strokeColor="#00000000" android:strokeWidth="1">
    <aapt:attr name="android:fillColor">

        <gradient android:endX="10.5" android:endY="15"
            android:startX="10.5" android:startY="0" android:type="linear">

            <item android:color="#FFFFD955" android:offset="0"/>
            <item android:color="#FFFCD036" android:offset="1"/>
        </gradient>
    </aapt:attr>
</path>

Please try this, if it could help as per your requirement:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="512dp"
android:height="512dp"
android:viewportWidth="512"
android:viewportHeight="512">
 <path
  android:pathData="M38.345,88.273C17.167,88.273 0,105.44 0,126.618v258.759c0,21.177 17.167,38.345 38.345,38.345h132.322V88.273H38.345z"
  android:fillColor="#FF0A3D9C"/>
<path
  android:pathData="M170.67,88.277h170.67v335.45h-170.67z"
  android:fillColor="#FFFFD955"/>
<path
  android:pathData="M473.655,88.273H341.333v335.448h132.322c21.177,0 38.345,-17.167 38.345,-38.345V126.618C512,105.44 494.833,88.273 473.655,88.273z"
  android:fillColor="#FFE5253D"/>
</vector>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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