How to set VectorDrawable as an image for ImageView programmatically

后端 未结 8 1605
梦如初夏
梦如初夏 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:18

    For those who want to load a vector drawable programmatically for other uses, such as setting a drawableLeft or otherwise, you can use:

    Drawable drawable = AppCompatResources.getDrawable(context, drawableRes);
    

    where the context is a AppCompatActivity.

提交回复
热议问题