android - 使用外部库: No resource identifier found for attribute

标签 android xml resources external

我正在使用BetterSpinner在我的应用程序中。

当我将 BetterSpinner 的 xml 添加到我的应用程序时,出现以下问题:

Namespace 'app' is not bound

我找到了解决方案here并将以下行添加到我的 xml 布局中:

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

现在不再有解析问题了。 但是当我尝试运行该应用程序时,出现编译错误:

Error:(32) No resource identifier found for attribute 'met_floatingLabel' in package 'com.example.jublikon'

我添加了这样的依赖项:

  compile ('com.weiwangcn.betterspinner:library-material:1.1.0') {
        exclude group: 'com.android.support', module: 'appcompat-v7'
        exclude group: 'com.rengwuxian.materialedittext', module: 'library'
    }

为什么Android Studio找不到gradle完全包含的库的资源?

我的完整 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"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="10"
    android:background="@color/colorPrimary"
    android:id="@+id/main">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_gravity="center"
        android:gravity="center"
        android:paddingLeft="32dp"
        android:layout_weight="3"
        android:textStyle="bold"
        android:textColor="@android:color/white"
        android:paddingRight="32dp"
        android:textSize="28sp"
        android:text="TITLE"
        android:id="@+id/title"/>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_weight="5">

        <com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner
            android:id="@+id/spinner2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="MaterialBetterSpinner"
            app:met_floatingLabel="normal" />

    </LinearLayout>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="3"
        android:layout_gravity="center"
        android:gravity="center"
        android:textColor="@android:color/white"
        android:paddingLeft="64dp"
        android:paddingRight="64dp"
        android:textSize="16sp"
        android:text="description"
        android:id="@+id/description" />
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="64dp" />
</LinearLayout>

最佳答案

根据 BetterSpinner Github 页面上的问题 #23: https://github.com/Lesilva/BetterSpinner/issues/23

您的依赖项中需要有 MaterialEditText 依赖项。

您是否像上面帖子中的人一样排除了它?

关于android - 使用外部库: No resource identifier found for attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34473556/

相关文章:

python - 使用python重复查询xml

java - 用于 war 部署的外部资源与内部资源,例如 Tomcat

c# - XmlSerializer + 抽象类 + 派生类 = 无用的命名空间

php - __在 PHP "Cannot use object of type stdClass as array"中获取资源

c# - 如何从 Designer.cs 文件访问内部静态字符串?

android - 将两个动画应用于同一 View ?

android - 具有不同上下文菜单的多个列表

android - 莫克西 : How pass params to Presenter?

javascript - Android WebView 上 JavaScript 的奇怪行为(使用 jQuery) 'scrollTop'

java - 如何在java中动态更改xml?