【问题标题】:vector drawable not visible in api level 15 even after using the appCompat library version 23.3.0即使在使用 appCompat 库版本 23.3.0 后,矢量可绘制对象在 api 级别 15 中也不可见
【发布时间】: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


【解决方案1】:

我找到了问题所在。 我正在使用这个

xmlns:app="http://schemas.android.com/tools"

而不是这个

xmlns:app="http://schemas.android.com/apk/res-auto"

在父布局中。

【讨论】:

  • 哇,这严重影响了代码我没有意识到这么容易犯这样的错误
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多