RT
这个问题困扰了我一个多小时。添加很简单,但怎么在绝对布局里添加到不同的位置讷?
最后还是翻文档的时候翻到了,可以在Layout.Children.Add时,设置第二参如new Point(x,y);,即可在绝对布局里设置其位置。
可惜这种方法还是耿直了点,看看能不能找到直接调用LayoutBounds的方法
AbsoluteLayout layout = (AbsoluteLayout)FindByName("AbLayout");
Grid g = new Grid();
Button btnLeft = new Button { Text = "Yes!",
BackgroundColor = Color.Beige,
FontSize = 15,
TextColor = Color.Pink,
CornerRadius = 50,
WidthRequest = 100,
HeightRequest = 100,
};
layout.Children.Add(btnLeft,new Point(0,200));
Button btnRight = new Button
{
Text = "No~",
BackgroundColor = Color.Beige,
FontSize = 15,
TextColor = Color.Pink,
CornerRadius = 50,
WidthRequest = 100,
HeightRequest = 100,
};
layout.Children.Add(btnRight,new Point(292,200));