Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
I have the following custom layout
public class SquareLayout : LinearLayout
public SquareLayout( IntPtr javaReference, JniHandleOwnership transfer )
: base( javaReference, transfer )
public SquareLayout( Context context ) :
base( context )
public SquareLayout( Context context, IAttributeSet attrs ) :
base( context, attrs )
When I add this layout to the axml, the VS designer is unable to render anything and I get the following error:
The layout could not be loaded: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
The same thing happens if I try to use some of the support views from API 13, like android.support.v4.view.PagerTabStrip.
I have the same problem.
I think the ability to render and interact with custom views needs to be prioritized highly. I am implementing Android version of existing MonoTouch app, and right now this is my #1 issue with Mono for Android. The layout system in Android is super powerful, and I use designer much more in MfA than Xcode view editor with MonoTouch (where I did almost all view design in code).
But with MfA, I am forced to not sub-class built-in views and view groups as much because I will loose all Designer support when I do so. But sub-classing is often a requirement to get some type of functionality that is not exposed publicly by Android class.
I think a basic short term solution could be to notice when a custom view is a sub-class of a native Android class, and simply interact with the native version in the Designer. So at design time no customizations, but at runtime instantiate the C# sub-class. At least for me, this would go a long way to reducing pain in this area.
Of course everything is ultimately a sub-class of View, so I suppose the rule would just be show/render super class that is in Android SDK.
The cast exception is fixed.
Adding support for custom view rendering is not trivial since the designer views are rendered by the Android SDK, which runs on Java. I'll leave this bug report open as an enhancement.
I was thinking something like this could be done:
Before passing of layout file to Java for display, see if custom types found are .NET. If so, use reflection to determine parent class that is not custom. Then use temporary layout definition that replaces custom view with standard view so that it can be rendered.
But I have no knowledge of the tools/architecture. I don't think the priority should be LOW. This is a major stumbling block to using the Designer and can force certain architectural decisions (helper classes vs. sub-classing).
I'll evaluate the viability of the option you propose.
*** Bug 3384 has been marked as a duplicate of this bug. ***
Any news on this problem ? This is really frustrating... we have a custom control wrapping all our view which make the designer useless. When we want to use the designer, we need to replace our custom control by the base control ( LinearLayout ), use the designer, then replace base control with our control.
No ETA for this yet. It's in the TODO list.
I have a circular dependecy here in my init method on the CropImageView...maybe you could help me out. https://github.com/slown1/Xamarin.CircleImageCropper
This is a major annoyance for my team as we have complex views embedded in custom viewgroups. Switching our custom viewgroups out for standard android ones in order to manipulate the design is a daily gripe and something we would be very keen to see resolved in a future Xamarin release.
We will have a middle ground solution for this akin to what was described in comment 5 for our 5.7 release.
Is that the next stable release?
This was actually pulled out of 5.7 because of other time constraining goals. It will be reinstated in 5.8 (which should hit stable roughly a month after 5.7).
As per comment 16, I am changing its target milestone as 5.8.