我正在尝试使用navigation drawer
创建Syncfusion SfNavigationDrawer
,但我在Android模拟器上遇到以下异常。
Java.Lang.NoSuchMethodError:类Lcom / xamarin / forms / platform / android / FormsViewGroup中没有name ='setClipToOutline'cignra ='(Z)V'的方法;
这是我的代码:
public class MainPage : ContentPage
{
public MainPage()
{
SfNavigationDrawer nav = new SfNavigationDrawer();
StackLayout mainStack = new StackLayout();
mainStack.Opacity = 1;
mainStack.Orientation = StackOrientation.Vertical;
mainStack.HeightRequest = 500;
mainStack.BackgroundColor = Color.White;
ObservableCollection<String> list = new ObservableCollection<string>();
list.Add("Home");
ListView listView = new ListView();
listView.WidthRequest = 200;
listView.VerticalOptions = LayoutOptions.FillAndExpand;
listView.ItemsSource = list;
mainStack.Children.Add(listView);
nav.DrawerContentView = mainStack;
StackLayout headerLayout = new StackLayout();
headerLayout.Orientation = StackOrientation.Vertical;
Image image = new Image();
image.Source = ImageSource.FromFile("user.png");
headerLayout.Children.Add(image);
Label header = new Label();
headerLayout.Children.Add(header);
nav.DrawerHeaderView = headerLayout;
Button imageButton = new Button();
imageButton.WidthRequest = 50;
Label homeLabel = new Label();
homeLabel.Text = "Home";
homeLabel.FontSize = 15;
homeLabel.TextColor = Color.White;
homeLabel.HorizontalTextAlignment = TextAlignment.Center;
homeLabel.VerticalTextAlignment = TextAlignment.Center;
StackLayout headerFrame = new StackLayout();
headerFrame.Orientation = StackOrientation.Horizontal;
headerFrame.Children.Add(imageButton);
headerFrame.Children.Add(homeLabel);
Label mainLabel = new Label();
mainLabel.Text = "Lorem...";
StackLayout ContentFrame = new StackLayout();
ContentFrame.Orientation = StackOrientation.Vertical;
ContentFrame.BackgroundColor = Color.White;
ContentFrame.Children.Add(headerFrame);
ContentFrame.Children.Add(mainLabel);
nav.ContentView = ContentFrame;
nav.Position = Position.Left;
nav.Transition = Transition.SlideOnTop;
this.Content = nav;
}
}
我正在使用Xamarin.Forms 2.3.0.49
和Syncfusion ES 14.2.0.26
。我应该注意更新Xamarin
和Android build-tools
没有帮助。
答案 0 :(得分:1)
这是lib中的已知错误。查看论坛here中的最新帖子。尝试使用this thread和this中的备用解决方案。
来自链接的摘要:
https://www.syntaxismyui.com/xamarin-forms-masterdetail-page-navigation-recipe/
https://varunrathore.wordpress.com/2015/03/10/xamarin-forms-navigation-drawer/
http://xforms-kickstarter.com/#a-slide-out-menu-using-a-master-detail-page
http://blog.falafel.com/xamarin-creating-a-sliding-tray/
希望它有所帮助!
答案 1 :(得分:1)
我遇到了同样的问题。 以下是Syncfusion支持团队的答案: 我们最新的Essential Studio Volume 2 Service Pack 2,2016(版本14.2.0.32)中已修复报告的崩溃“没有名称为setClipOutline的方法”,可通过以下链接下载。
问题解决了。