【发布时间】:2016-08-30 09:12:50
【问题描述】:
我在 API 级别 15 的 ImageView 中使用可绘制矢量。我在我的 gradle 中使用 AppCompat 库版本“appcompat-v7:23.3.0”,它为 SVG 提供了对较低 API 级别的支持。
这是我的 ImageView 的 XML:
<ImageView
app:srcCompat="@drawable/check"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_below="@+id/ivProduct"
android:layout_alignParentRight="true"
android:paddingRight="@dimen/product_card_view_content_padding"
android:id="@+id/ivAddedToCart"
android:focusable="true"/>
这是drawable文件夹中的check.xml:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M9,16.2l-4.2,-4.2l-1.4,1.4l5.6,5.6l12,-12l-1.4,-1.4z"/>
ImageView 根本没有显示。谁能告诉我我在做什么错误。
【问题讨论】:
-
您的 logcat 中是否有任何错误?您是否在构建文件中添加了
vectorDrawables.useSupportLibrary = true?
标签: android svg imageview android-support-library android-vectordrawable