MonoDroid的 - 设置背景颜色从colors.xml抛出InvalidOperationException异常 [英] MonoDroid - setting background color from colors.xml throws InvalidOperationException

查看:108
本文介绍了MonoDroid的 - 设置背景颜色从colors.xml抛出InvalidOperationException异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的布局如下:

I have a simple layout as follows:

<?xml version="1.0" encoding="utf-8"?>
  <LinearLayout
  android:id="@+id/widget30"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@color/translucent_red"
  android:orientation="vertical"
  xmlns:android="http://schemas.android.com/apk/res/android">

我colors.xml文件如下:

My colors.xml file is as follows:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <color name="opaque_red">#f00</color>
  <color name="translucent_red">#80ff0000</color>
</resources>

当我在VS2010编译我得到一个错误System.InvalidOperationException:命令失败......我试图放在RES /价值观和RES /颜色,但我仍然是colors.xml
得到的错误。如果我引用的颜色直接,如:

When I compile in VS2010 I get an error "System.InvalidOperationException: Command failed...." I have tried to place the colors.xml in res/values and res/color but I still get the error. If I reference the color directly like:

android:background="#80ff0000"

一切工作正常。

有谁知道,如果colors.xml由MonoDroid的,并支持如果是这样,为什么我得到这个错误?

Does anyone know if the colors.xml is supported by MonoDroid and if so why I'm getting this error?

感谢您的帮助!

推荐答案

想通了,对于colors.xml生成操作设置为内容,而不是AndroidResource!

Figured it out, the Build Action for colors.xml was set to Content instead of AndroidResource !

这篇关于MonoDroid的 - 设置背景颜色从colors.xml抛出InvalidOperationException异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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