在包"learnapp.android.example.com.learnapp"中找不到属性"srcCompat"的资源标识符 [英] No resource identifier found for attribute 'srcCompat' in package 'learnapp.android.example.com.learnapp'

查看:63
本文介绍了在包"learnapp.android.example.com.learnapp"中找不到属性"srcCompat"的资源标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到Error:(26) No resource identifier found for attribute 'srcCompat' in package 'learnapp.android.example.com.learnapp' 当我尝试运行我的应用程序时,我今天才开始学习android.我添加了一个新活动,并在任何xml文件中进行了更改.

I am getting Error:(26) No resource identifier found for attribute 'srcCompat' in package 'learnapp.android.example.com.learnapp' when I try to run my app.I have just started learning android today.I have added a new activity and dint change anything in any xml files.

这是确切的错误:

Documents/MyProjects/LearnApp/app/src/main/res/layout/activity_display_message.xml
Error:(26) No resource identifier found for attribute 'srcCompat' in package 'learnapp.android.example.com.learnapp'

这是我的activity_display_message.xml

Here is my activity_display_message.xml

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="learnapp.android.example.com.learnapp.DisplayMessageActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_display_message" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@android:drawable/ic_dialog_email" />

</LinearLayout>

我已经阅读过类似的问题,并且看到其中任一行

I have already read similar questions and saw that either the line

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

app:srcCompat="@android:drawable/ic_dialog_email" />

在他们的情况下是错误的,在我的情况下不是.

was wrong in their case which is not in my case.

如果此活动的父活动是MainActivity.java,则很重要

Incase it matters this activity's parent activity is MainActivity.java

推荐答案

我刚刚更改

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

xmlns:app="http://schemas.android.com/apk/lib/my_package_name"

我在此处看到了答案

这篇关于在包"learnapp.android.example.com.learnapp"中找不到属性"srcCompat"的资源标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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