gpt4 book ai didi

android - 在包中找不到属性 'srcCompat' 的资源标识符

转载 作者:行者123 更新时间:2023-11-30 00:54:51 25 4
gpt4 key购买 nike

最后 Android studio 得到问题:

Error:(11) No resource identifier found for attribute 'srcCompat' in package 'com.example.NAMEGAME'

我想在布局中添加 gif 动画。我的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.NAMEGAME.forma1"
android:id="@+id/forma1">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@drawable/forma1gif"
/>
</LinearLayout>

我在 xmlns:app="http://schemas.android.com/apk/res-auto" 中发现了这个问题。有些人建议将其更改为 xmlns:app="http://schemas.android.com/apk/lib/com.example.NAMEGAME".但这无济于事。

如何在我的 android 项目中添加 gif 动画(或使用应用程序)?

附注对不起我的英语。

最佳答案

如果您想使用vector 可绘制对象,您必须在build.gradle 文件中添加一条语句。

android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}

dependencies {
compile 'com.android.support:appcompat-v7:24.2.1'
}

然后在 layout.xml 文件中添加 xmlns:app="http://schemas.android.com/apk/res-auto"。之后,您可以将 app:srcCompat 用于矢量绘图。

See more details here.

关于android - 在包中找不到属性 'srcCompat' 的资源标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40340556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com