Android vector drawable app:srcCompat not showing images

前端 未结 8 707
误落风尘
误落风尘 2020-11-28 04:38

I\'m using support library to show vector images on android kitkat. When I test my app on emulater I don\'t see any of these images. I made a separate layout for android lol

8条回答
  •  北海茫月
    2020-11-28 05:01

    In summary:

    1. Put vector drawable support in your module (build.gradle)

      defaultConfig {           
           vectorDrawables.useSupportLibrary = true
       }
      
    2. Instead of android:src="@drawable/icon" use app:srcCompat="@drawable/icon"

    3. Make sure your Activity extends AppCompatActivity without this step is not possible to show vector image with app:srcCompat

提交回复
热议问题