Android 层列表 : bitmap issue with app:srcCompat

标签 android bitmap android-studio-2.3

更新到 Studio 2.3 后,当我尝试使用可绘制矢量创建图层列表时,它会提示在 中使用 app:srcCompat 而不是 android:src位图.

谁能帮我把vector drawable添加到图层列表

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@color/colorWhite" />

<item>
    <bitmap
        android:gravity="center"
        app:srcCompat="@drawable/login">
    </bitmap>

</item>

</layer-list>

已经添加

vectorDrawables.useSupportLibrary = true

最佳答案

我找到了解决您问题的方法

将第二项修改为:

<item android:gravity="center" android:drawable="@drawable/login"/>

更新

这将导致 API < 21 崩溃。没有更好的方法。

关于Android 层列表 : bitmap issue with app:srcCompat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42691452/

相关文章:

支持 alpha channel 的 Android opengl 屏幕截图

c# - 如何确定 GIF 中的像素是否透明 (.NET)

bitmap - 将指纹位图转换为 ISO/IEC 19794-2 模板

Android Studio 2.3.3 首次运行时卡住

java - Imagebutton.setImageURI(uri) 不起作用

android - 如何为 android 应用程序加密 SQlite 数据库?

java - 摆脱操作栏

android - 借助 MergeAdapter、StickyListHeaders 和 ListViewAnimations 的强大功能,我是 Android 的队长

java - 想要通过 joda 获取两个不同时区的两个 ISO 8601 时间之间的分钟数

android - android studio 更新后 ADB 不工作