您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

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

如何在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 。

其他 2022/1/1 18:14:17 有532人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶