我在安卓项目中动态展示一些VectorDrawable图标。然而,我无法使用下面的代码在Java层缩放这些图标:
VectorDrawable jDrawable = (VectorDrawable) getContext().getDrawable(nResourceID);
// resize the icon
jDrawable.setBounds(30, 30, 30, 30);
// set the icon in the button view
button.setCompoundDrawablesRelativeWithIntrinsicBounds(jDrawable, null, null, null);
注意: Android如何在程序中动态调整(缩放)XML矢量图标的大小,但该答案并未解决我的问题。