在ImageView中设置矢量Drawable导致应用程序在旧SDK中崩溃 [英] Set Vector Drawable in ImageView cause app crash in old SDK

查看:508
本文介绍了在ImageView中设置矢量Drawable导致应用程序在旧SDK中崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在图像src中使用Vector Drawable,如下所示:

I used Vector Drawable in image src like this:

 <ImageView
                android:id="@+id/isSold"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center_vertical"
                android:visibility="gone"
                app:srcCompat="@drawable/ic_soldout_24px"
                tools:ignore="MissingPrefix"/>

我还将这些添加到清单:

I also added these to manifest:

defaultConfig {
        vectorDrawables.useSupportLibrary=true
    }

我使用 compile'c​​om.android.support:appcompat-v7:23.2.1'

但我的应用程式在旧sdk中的消息错误充气类ImageView

but my app crashes in old sdk with message of Error inflating class ImageView

推荐答案

使用 android.support.v7.widget.AppCompatImageView 而不是ImageView:

Use android.support.v7.widget.AppCompatImageView instead of ImageView:

 <android.support.v7.widget.AppCompatImageView
    android:id="@+id/isSold"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_vertical"
    android:visibility="gone"
    app:srcCompat="@drawable/ic_soldout_24px"
    tools:ignore="MissingPrefix"/>

这篇关于在ImageView中设置矢量Drawable导致应用程序在旧SDK中崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆