即使在使用 appCompat 库版本 23.3.0 后,矢量绘图在 api 级别 15 中也不可见
vector drawable not visible in api level 15 even after using the appCompat library version 23.3.0
我在 API 级别 15 的 ImageView 中使用矢量可绘制对象。我在我的 gradle 中使用 AppCompat 库版本 "appcompat-v7:23.3.0",它引入了对 SVG 的支持对于较低的 API 级别。
这是我的 XML ImageView:
<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"/>
这是可绘制文件夹中的 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 根本没有显示。谁能告诉我我做错了什么。
我找到了问题所在。
我正在使用这个
xmlns:app="http://schemas.android.com/tools"
而不是这个
xmlns:app="http://schemas.android.com/apk/res-auto"
在父布局中。
我在 API 级别 15 的 ImageView 中使用矢量可绘制对象。我在我的 gradle 中使用 AppCompat 库版本 "appcompat-v7:23.3.0",它引入了对 SVG 的支持对于较低的 API 级别。
这是我的 XML ImageView:
<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"/>
这是可绘制文件夹中的 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 根本没有显示。谁能告诉我我做错了什么。
我找到了问题所在。 我正在使用这个
xmlns:app="http://schemas.android.com/tools"
而不是这个
xmlns:app="http://schemas.android.com/apk/res-auto"
在父布局中。