How to set VectorDrawable as an image for ImageView programmatically

后端 未结 8 1601
梦如初夏
梦如初夏 2020-12-13 05:58

I want to set some vectorDrawables to a ImageView in Android Studio.

I can set png and jpg drawable easily but when i want to set V

8条回答
  •  不知归路
    2020-12-13 06:13

    As per official android developer blog, no changes for setImageResource() method at runtime for vectorDrawables.

    If you’re changing drawables at runtime, you’ll be able to use the same setImageResource() method as before - no changes there. Using AppCompat and app:srcCompat is the most foolproof method of integrating vector drawables into your app.

    For more details, check out this nice article AppCompat — Age of the vectors by Google Developer.

提交回复
热议问题