[mono-android] XML Drawable Resource as background won't compile

Nathan Blevins nblevins at nathanblevins.com
Wed Mar 9 22:53:58 EST 2011


Hey all,

I have an odd issue that I am hoping is due to the fact that I do not have
enough caffiene in my system.  Bascially, I am trying to define a shape
drawable via XML and set it as the background to a layout element.  Here is
my drawable syntax located within a file called ShapeDrawableDemo.xml within
the Drawable directory:

<?xml version="1.0" encoding="utf-8" ?><shape
xmlns:android="http://schemas.android.com/apk/res/android">	<gradient
android:angle="180" android:startColor="#FFFFFF"
android:endColor="#000000"/></shape>

Now, I have modified my main.axml file to use this drawable as a background
like this:

<?xml version="1.0" encoding="utf-8"?><LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"		android:orientation="vertical"		android:layout_width="fill_parent"		android:layout_height="fill_parent"		>	<Button
android:id="@+id/MyImage"		android:layout_width="fill_parent"		android:layout_height="wrap_content"
		android:background="@drawable/ShapeDrawableDemo"
		android:text="Testing"/></LinearLayout>

For some reason, I am getting a build error that says:

Error 3 No resource found that matches the given name (at 'background' with
value '@drawable/ShapeDrawableDemo'). G:\Projects\Monodroid
Book\Graphics_Drawables\Graphics_Drawables\Resources\Layout\Main.axml 14
Graphics_Drawables

If I use this drawable via code-behind, it works perfectly.

Console.WriteLine(Resource.Drawable.ShapeDrawableDemo.ToString() + " -
This works and has an ID!");

Here is my autogenned R file:

public partial class Drawable
{
	
	// aapt resource value: 0x7f020000
	public const int Icon = 2130837504;
	
	// aapt resource value: 0x7f020001
	public const int ShapeDrawableDemo = 2130837505;
			
	private Drawable()
	{
	}
}


Any suggestions?  Am I somehow futzing up the syntax somewhere?  Thanks,

Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110309/ed55928a/attachment.html 


More information about the Monodroid mailing list