使用 Xamarin.forms 绘制多边形
Draw a Polygon with Xamarin.forms
我想知道是否可以用 Xamarin.Forms 做这样的事情。
我已经可以像这样分离我的布局,但我想知道我该怎么做才能绘制一个多边形?或者也许还有其他方法可以实现这一目标?像 drawable 这样更好的方法?但它需要在每台设备上都相同......
// Relative Layouts
this.contentLayout = new RelativeLayout();
this.topLayout = new RelativeLayout();
this.bottomLayout = new RelativeLayout();
//topLayout.BackgroundColor = Color.FromHex("#00162E");
//bottomLayout.BackgroundColor = Color.FromHex("#FFFFFF");
// Top and Bottom Layouts
this.contentLayout.Children.Add(
topLayout,
Constraint.RelativeToParent((parent) => { return 0; }),
Constraint.RelativeToParent((parent) => { return 0; }),
Constraint.RelativeToParent((parent) => { return parent.Width; }),
Constraint.RelativeToParent((parent) => { return (parent.Height/2.5); })
);
this.contentLayout.Children.Add(
bottomLayout,
Constraint.RelativeToParent((parent) => { return 0; }),
Constraint.RelativeToParent((parent) => { return this.topLayout.Height; }),
Constraint.RelativeToParent((parent) => { return parent.Width; }),
Constraint.RelativeToParent((parent) => { return (parent.Height / 1.5); })
);
// Inside Top Layout
// ??? Draw Polygon
// Inside Bottom Layout
谢谢大家!
祝你有愉快的一天!
我想知道是否可以用 Xamarin.Forms 做这样的事情。
我已经可以像这样分离我的布局,但我想知道我该怎么做才能绘制一个多边形?或者也许还有其他方法可以实现这一目标?像 drawable 这样更好的方法?但它需要在每台设备上都相同......
// Relative Layouts
this.contentLayout = new RelativeLayout();
this.topLayout = new RelativeLayout();
this.bottomLayout = new RelativeLayout();
//topLayout.BackgroundColor = Color.FromHex("#00162E");
//bottomLayout.BackgroundColor = Color.FromHex("#FFFFFF");
// Top and Bottom Layouts
this.contentLayout.Children.Add(
topLayout,
Constraint.RelativeToParent((parent) => { return 0; }),
Constraint.RelativeToParent((parent) => { return 0; }),
Constraint.RelativeToParent((parent) => { return parent.Width; }),
Constraint.RelativeToParent((parent) => { return (parent.Height/2.5); })
);
this.contentLayout.Children.Add(
bottomLayout,
Constraint.RelativeToParent((parent) => { return 0; }),
Constraint.RelativeToParent((parent) => { return this.topLayout.Height; }),
Constraint.RelativeToParent((parent) => { return parent.Width; }),
Constraint.RelativeToParent((parent) => { return (parent.Height / 1.5); })
);
// Inside Top Layout
// ??? Draw Polygon
// Inside Bottom Layout
谢谢大家!
祝你有愉快的一天!