3 回答

TA贡献1828条经验 获得超4个赞
支持库支持Lollipop之前的VectorDrawable,但使用它们的方式取决于您所拥有的支持库的版本。而且它不一定在所有情况下都有效。
我制作了此图来提供帮助(对于支持库23.4.0至-至少-25.1.0有效)。

TA贡献1757条经验 获得超7个赞
借助23.2支持库,一直到API v7一直对Vector Drawable提供真正的支持。建议通过添加以下内容来禁用该支持的先前版本:该支持在构建期间呈现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 。
但是,我仍然建议使用Iconics库,AndroidSVG或其他字体图标或SVG解决方案,以全面支持SVG标准。
添加回答
举报