Bug 10846 - Designer fails on custom drawable in layout (Xamarin Studio 4.0, Mac)
Summary: Designer fails on custom drawable in layout (Xamarin Studio 4.0, Mac)
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Designer ()
Version: 4.6.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Lluis Sanchez
URL:
Depends on:
Blocks:
 
Reported: 2013-03-03 02:25 UTC by NeoDarque
Modified: 2013-03-15 11:08 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test project to showcase bug (4.26 MB, application/zip)
2013-03-13 13:31 UTC, NeoDarque
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description NeoDarque 2013-03-03 02:25:23 UTC
If I create a layout for a listitem which refers to a custom drawable that is a selector, the designer shows an Exception: "The layout could not be loaded: Exception of type 'Xamarin.AndroidDesigner.DesignerException'", so it's only possible to edit this layout in source mode. Changing the "android:background" to something like "@android:color/white" will make the designer work, but again, with a custom drawable it doesn't work.

In my case the layout is named "listitem_menu.axml" and looks like this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="44dp"
    android:background="@drawable/listItemBackground"
    android:padding="2dp">
    <TextView
        android:id="@+id/chevron"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/darker_gray"
        android:textSize="16dip"
        android:textStyle="italic"
        android:text="&gt;"
        android:layout_gravity="center_vertical"
        android:layout_centerVertical="true"
        android:layout_marginRight="6dp"
        android:layout_marginLeft="6dp"
        android:layout_alignParentRight="true" />
    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@android:color/black"
        android:textSize="16dip"
        android:textStyle="italic"
        android:layout_gravity="center_vertical"
        android:layout_centerVertical="true"
        android:layout_marginRight="18dp"
        android:layout_marginLeft="6dp" />
</RelativeLayout>

and the custom drawable is named "listItemBackground.axml" and looks like this:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
	<item android:state_pressed="false"
  	      android:state_selected="false"
	      android:drawable="@drawable/CellBackgroundTransparent">
	</item>
	<item android:state_selected="true"
	      android:state_pressed="false"        
	      android:drawable="@android:color/white">
	</item>
	<item android:state_pressed="true" >
		<shape>
			<gradient android:startColor="#666666" android:endColor="#666666" android:angle="270" />
		</shape>
	</item>
</selector>

the drawable referenced here in the first item is an image.
Comment 1 Lluis Sanchez 2013-03-13 04:34:37 UTC
Do you have a simple test project that can be used to reproduce the problem? it would be helpful to diagnose the problem.
Comment 2 NeoDarque 2013-03-13 13:31:39 UTC
Created attachment 3601 [details]
Test project to showcase bug

When I re-created a project from scratch implementing the same designer files, the designer doesn't crash like in my solution, but it only shows black instead of the drawable it should be showing.

You can get the same exception with this test project though if you open the list item_menu.axml file in the designer, and for background try to select the listitemBackground.axml drawable. The designer shows the same exception I get in my real solution by only opening any of the listitem* layouts.
Comment 3 Lluis Sanchez 2013-03-15 11:08:24 UTC
The Android SDK is picky about the extension of drawable files. The extension of the drawable has to be .xml, not .axml. The designer will be able to load the layout if you rename the drawable. In any case, the designer should not crash in that way. It will now be able to load the layout, even though it won't be able to show the background correctly.