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

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

问题描述

我是这个Android开发的新手,我发现它的布局确实令人困惑.我正在尝试在视图上显示背景图像,并且尝试使用此示例 添加背景图像以在xml Android中成形,但是看起来很糟糕(您知道位图)

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" />

它在设计视图和所有视图中呈现,但是属性viewportWidthviewportHeightfillColorpathData都显示相同的警告:

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.

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

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>

推荐答案

问题

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

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

解决方案

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

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
  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.0 \ Xml \ Schemas,或者只需在Visual Studio中添加这些架构即可.该错误将消失,我已通过此过程解决了该问题.

Just download and move files manually to C:\Program Files (x86)\Microsoft Visual Studio 14.0\Xml\Schemas 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天全站免登陆