【问题标题】:Xamarin layout designer error for support controls支持控件的 Xamarin 布局设计器错误
【发布时间】:2017-05-17 21:20:44
【问题描述】:

支持设计库中的控件未显示在布局设计器预览中。

“显示错误”按钮没有任何作用

这是我的 axml 源代码

 <?xml version="1.0" encoding="utf-8"?> 
  <android.support.design.widget.CoordinatorLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"     
  xmlns:app="http://schemas.android.com/apk/res-auto"     
  android:orientation="vertical"  
  android:layout_width="match_parent"  
  android:layout_height="match_parent"> 
  <android.support.v4.view.ViewPager  
   android:id="@+id/viewpager"  
   android:layout_width="match_parent"         
  android:layout_height="match_parent"         
 app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 
 </android.support.design.widget.CoordinatorLayout>

还有一些来自 xamarin 日志文件的例外情况

    System.NullReferenceException: Object reference not set to an instance of an object.    at Xamarin.AndroidDesigner.VisualItems.ExceptionCalloutButton.CreateExceptionPopoverContent() in C:\d\lanes\4471\3f99c5a7\source\xamarinvs\External\md-addins\MonoDevelop.MonoDroid\Xamarin.AndroidDesigner\Xamarin.AndroidDesigner.VisualItems\ExceptionCalloutButton.cs:line 55    at Xamarin.AndroidDesigner.VisualItems.ExceptionCalloutButton.ShowExceptionPopover() in C:\d\lanes\4471\3f99c5a7\source\xamarinvs\External\md-addins\MonoDevelop.MonoDroid\Xamarin.AndroidDesigner\Xamarin.AndroidDesigner.VisualItems\ExceptionCalloutButton.cs:line 45    at Xamarin.AndroidDesigner.VisualItems.ExceptionCalloutButton.OnShowErrorButtonClicked(Object sender, EventArgs e) in C:\d\lanes\4471\3f99c5a7\source\xamarinvs\External\md-addins\MonoDevelop.MonoDroid\Xamarin.AndroidDesigner\Xamarin.AndroidDesigner.VisualItems\ExceptionCalloutButton.cs:line 32    at Xamarin.Designer.VisualItem.OnClicked() in C:\d\lanes\4471\3f99c5a7\source\xamarinvs\External\md-addins\Xamarin.Designer\Xamarin.Designer\VisualItem.cs:line 692    at Xamarin.Designer.VisualItems.ButtonItem.OnClicked() in C:\d\lanes\4471\3f99c5a7\source\xamarinvs\External\md-addins\Xamarin.Designer\Xamarin.Designer.VisualItems\ButtonItem.cs:line 84    at Xamarin.Designer.VisualItem.OnButtonReleased(ButtonEventArgs args) in C:\d\lanes\4471\3f99c5a7\source\xamarinvs\External\md-addins\Xamarin.Designer\Xamarin.Designer\VisualItem.cs:line 674    at Xamarin.Designer.DesignerSurface.ReleaseButtonOnItem(VisualItem vi, ButtonEventArgs args) in C:\d\lanes\4471\3f99c5a7\source\xamarinvs\External\md-addins\Xamarin.Designer\Xamarin.Designer\DesignerSurface.cs:line 590    at Xamarin.Designer.DesignerSurface.OnButtonReleased(ButtonEventArgs args) in C:\d\lanes\4471\3f99c5a7\source\xamarinvs\External\md-addins\Xamarin.Designer\Xamarin.Designer\DesignerSurface.cs:line 609    at Xamarin.Designer.DesignerSurface.ButtonReleased(ButtonEventArgs args) in C:\d\lanes\4471\3f99c5a7\source\xamarinvs\External\md-addins\Xamarin.Designer\Xamarin.Designer\DesignerSurface.cs:line 571    at Xamarin.Designer.Windows.EventUtils.ForwardButtonEvent(Action1 action, Object sender, MouseButtonEventArgs e) in C:\d\lanes\4471\3f99c5a7\source\xamarinvs\External\md-addins\Xamarin.Designer\Xamarin.Designer.Windows\EventUtils.cs:line 22
at Xamarin.Designer.Windows.WpfSurfaceRenderer.<>c__DisplayClass79_0.b__4(Object sender, MouseButtonEventArgs e) in C:\d\lanes\4471\3f99c5a7\source\xamarinvs\External\md-addins\Xamarin.Designer\Xamarin.Designer.Windows\WpfSurfaceRenderer.cs:line 586
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

更新:我从 nuget 添加了所有支持设计库包

【问题讨论】:

  • 按钮的 xml 代码在哪里?
  • @Yupi 我的布局中没有按钮。此按钮由 xamarin 绘制
  • NullReferenceException 表示您正在尝试对这种情况下不存在的按钮执行某些操作。因此,您的按钮在布局中不存在,或者您的 id 错误。
  • 你是否为支持库添加了 nuget 包?
  • @ Yupi 我知道NullReferenceException 是什么意思。我说你那不是我的按钮。不是!,我的布局文件中没有它的 axml 代码。这个按钮是 xamarin 的。

标签: android xamarin xamarin.android


【解决方案1】:

我找到了解决方案。问题是支持控件只有在布局设计器窗口中选择了appcompat主题时才能呈现。

【讨论】:

    猜你喜欢
    • 2016-07-17
    • 1970-01-01
    • 1970-01-01
    • 2018-06-08
    • 2015-08-24
    • 1970-01-01
    • 1970-01-01
    • 2010-11-25
    • 1970-01-01
    相关资源
    最近更新 更多