我尝试从我用于我的 Android 应用程序的库中自定义一个 View 。默认的 xml 代码如下所示:
<it.gmariotti.cardslib.library.view.CardView
android:id="@+id/carddemo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"/>
这没有任何问题。但是当我在元素中添加一个新行时,为了使用我的自定义布局,我在开始行中收到一个错误,您可以在这个问题的标题中看到:这是我最后添加的行:
card:card_layout_resourceID="@layout/custom_layout" />
这也是库文档中用作示例的代码。
最佳答案
您可能忘记了为自定义属性card
“定义”命名空间。因此,将此添加到您的 xml 文件
中的 root-view:
xmlns:card="http://schemas.android.com/apk/res-auto"
关于android - 解析 XML 时出错 : unbound prefix in custom view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25832023/