该属性未在基本 xml 属性上声明 (Android) [英] The attribute is not declared (Android) on basic xml attributes

查看:24
本文介绍了该属性未在基本 xml 属性上声明 (Android)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是这个 Android 开发的新手,我发现它的布局真的很混乱.我正在尝试在视图上显示背景图像,并且我尝试使用此示例

请注意,如果我删除警告前面的android",它会删除警告但仍然给我相同的部署错误

Android.Views.InflateException:二进制 XML 文件第 1 行:错误膨胀类 <unknown>

解决方案

问题

Intellisense 无法选择我们键入的属性,尽管这些属性存在于 android SDK 中并显示未声明此属性.

解决方案

我昨天在 Visual Studio 2015 中遇到了这个问题并开始搜索这个问题,最终我发现 Visual Studio 中的 XML schema 文件夹中缺少这两个文件,因此下载下面给出的这些文件链接,

  1. https://github.com/atsushieno/monodroid-schema-gen/blob/master/android-layout-xml.xsd
  2. https://github.com/atsushieno/monodroid-schema-gen/blob/master/schemas.android.com.apk.res.android.xsd

只需手动下载文件并将其移动到 C:Program Files (x86)Microsoft Visual Studio 14.0XmlSchemas 或只需在 Visual Studio 中添加这些架构.这个错误会消失,我用这个程序解决了这个问题.

I'm new to this Android development, and I find the layout of it really confusing. I'm trying to have a background image on a view, and I've tried using this example Add a background image to shape in xml Android, but it looks very bad (bitmaps you know)

So I thought vectors could be fun. Only problem is that I cannot get even the official examples to work. I've tried setting this as a background

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="256dp"
    android:width="256dp"
    android:viewportWidth="32"
    android:viewportHeight="32">
<path android:fillColor="#8fff" android:pathData="M20.5,9.5
                  c-1.955,0,-3.83,1.268,-4.5,3
                  c-0.67,-1.732,-2.547,-3,-4.5,-3
                  C8.957,9.5,7,11.432,7,14
                  c0,3.53,3.793,6.257,9,11.5
                  c5.207,-5.242,9,-7.97,9,-11.5
                  C25,11.432,23.043,9.5,20.5,9.5z" />

It renders in the design view and all, but the attributes viewportWidth, viewportHeight, fillColor and pathData all show the same warning:

The 'http://schemas.android.com/apk/res/android:viewportWidth' is not declared

If I check the file, sure enough, it's not there. Does that mean I have to explicitly declare all those types? It seems a bit odd for vanilla examples.

Note that if I remove the 'android' in front of the warnings, it will remove warnings but still give me the same deployment error

Android.Views.InflateException: Binary XML file line #1: Error inflating class <unknown>

解决方案

Problem

Intellisense could not pick the attributes we type although those attributes are existing in android SDK and shows this Attribute is not declared.

Solution

I got this problem yesterday in Visual Studio 2015 and started searching about this, ultimately I found that these two files are missing in XML schema folder in Visual Studio, so download these files links given below,

  1. https://github.com/atsushieno/monodroid-schema-gen/blob/master/android-layout-xml.xsd
  2. https://github.com/atsushieno/monodroid-schema-gen/blob/master/schemas.android.com.apk.res.android.xsd

Just download and move files manually to C:Program Files (x86)Microsoft Visual Studio 14.0XmlSchemas or simply just add these schemas within Visual Studio. This error will be gone, I resolved this issue with this procedure.

这篇关于该属性未在基本 xml 属性上声明 (Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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