如何在Android API下21中使用矢量可绘制对象?

如何在Android API下21中使用矢量可绘制对象?,第1张

如何在Android API下21中使用矢量可绘制对象?

使用支持库23.2,一直到API v7都对Vector Drawables提供了真正的支持。建议通过添加以下内容来禁用该支持的先前版本:该支持在​​构建期间呈现PNG

// Gradle Plugin 2.0+ android {   defaultConfig {     vectorDrawables.useSupportLibrary = true    } }

build.gradle
文件。

实现非常简单。只需在Drawables上使用新的srcCompat属性即可:

<ImageView  android:layout_width="wrap_content"  android:layout_height="wrap_content"  app:srcCompat="@drawable/ic_add" />    <= this is new

在诸如TextView的

drawableLeft
属性的情况下,也支持Vector Drawable 。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5100809.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-16
下一篇 2022-11-16

发表评论

登录后才能评论

评论列表(0条)

保存