【发布时间】:2016-05-05 16:32:48
【问题描述】:
我是这个 Android 开发的新手,我发现它的布局真的很混乱。我正在尝试在视图上添加背景图像,并且尝试使用此示例 Add a background image to shape in xml Android,但是看起来很糟糕(你知道的位图)
所以我认为向量可能很有趣。唯一的问题是我什至无法让官方示例正常工作。我试过把它设置为背景
<?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" />
它在设计视图和所有视图中呈现,但属性viewportWidth、viewportHeight、fillColor 和pathData 都显示相同的警告:
The 'http://schemas.android.com/apk/res/android:viewportWidth' is not declared
如果我检查文件,果然,它不存在。这是否意味着我必须明确声明所有这些类型?香草的例子似乎有点奇怪。
请注意,如果我删除警告前面的“android”,它会删除警告但仍然给我同样的部署错误
Android.Views.InflateException: Binary XML file line #1: Error inflating class <unknown>
【问题讨论】:
-
您正在运行 Visual Studio 的
Xamarin的哪个版本?哪个版本的Visual Studio?哪个Android SDK版本? -
@SushiHangover Visual studio 2015 14.0.25123, Xamarin 4.0.3, Xamarin.Android 6.0.3.5 看来我安装的最新SDK是API 22 (5.1.1)
-
@SushiHangover 我现在已经升级到了最新的 SDK,但是很遗憾,什么都没有改变