Search code examples
androidxmlandroid-vectordrawable

android:fillType="evenOdd" is not working in api 23 - vector drawable Any alternate solution?


Any alternative solution?

Vector drawable code

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
  <path
      android:pathData="M6.5,22.4235L17.995,22.4235L17.995,10.9285L6.5,10.9285L6.5,22.4235ZM8.068,6.6785C8.068,4.3745 9.943,2.4995 12.247,2.4995C14.551,2.4995 16.426,4.3745 16.426,6.6785L16.426,9.4285L8.068,9.4285L8.068,6.6785ZM11.4971,16.6426C10.7691,16.3456 10.2551,15.6336 10.2551,14.7986C10.2551,13.6996 11.1471,12.8076 12.2471,12.8076C13.3481,12.8076 14.2391,13.6996 14.2391,14.7986C14.2391,15.6336 13.7261,16.3456 12.9971,16.6426L12.9971,19.8826L11.4971,19.8826L11.4971,16.6426ZM17.926,9.4285L17.926,6.6785C17.926,3.5475 15.378,0.9995 12.247,0.9995C9.116,0.9995 6.568,3.5475 6.568,6.6785L6.568,9.4285L5,9.4285L5,23.9235L19.495,23.9235L19.495,9.4285L17.926,9.4285Z"
      android:strokeWidth="1"
      android:fillColor="#000000"
      android:fillType="evenOdd"
      android:strokeColor="#00000000"/>
</vector>

gradle:

 minSdkVersion = 21
    targetSdkVersion = 28
    compileSdkVersion = 28

Attribute fillType is only used in API level 24 and higher (current min is 1) less... (⌘F1)

This check finds attributes set in XML files that were introduced in a version newer than the oldest version targeted by your application (with the minSdkVersion attribute). This is not an error; the application will simply ignore the attribute.

However, if the attribute is important to the appearance or functionality of your application, you should consider finding an alternative way to achieve the same result with only available attributes, and then you can optionally create a copy of the layout in a layout-vNN folder which will be used on API NN or higher where you can take advantage of the newer attribute. Note:

This check does not only apply to attributes. For example, some tags can be unused too, such as the new element in layouts introduced in API 21. Issue id: UnusedAttribute enter image description here

warning


Solution

  • This is the solution I used to solve this issue.

    <vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24"
        android:viewportHeight="24">
      <path
          android:pathData="M6.5,10.9235L17.995,10.9235L17.995,22.385L6.5,22.385L6.5,22.4235ZM8.068,6.6785C8.068,4.3745 9.943,2.4995 12.247,2.4995C14.551,2.4995 16.426,4.3745 16.426,6.6785L16.426,9.4285L8.068,9.4285L8.068,6.6785ZM11.4971,16.6426C10.7691,16.3456 10.2551,15.6336 10.2551,14.7986C10.2551,13.6996 11.1471,12.8076 12.2471,12.8076C13.3481,12.8076 14.2391,13.6996 14.2391,14.7986C14.2391,15.6336 13.7261,16.3456 12.9971,16.6426L12.9971,19.8826L11.4971,19.8826L11.4971,16.6426ZM17.926,9.4285L17.926,6.6785C17.926,3.5475 15.378,0.9995 12.247,0.9995C9.116,0.9995 6.568,3.5475 6.568,6.6785L6.568,9.4285L5,9.4285L5,23.9235L19.495,23.9235L19.495,9.4285L17.926,9.4285Z"
          android:strokeWidth="1"
          android:fillColor="#000000"
          android:strokeColor="#00000000"/>
    </vector>