标签:style io os ar 使用 for sp on ad
App entrance:
namespace first_portable_demo
{
public class App
{
public static Page GetMainPage()
{
return new GreetingsPage();
}
}
}
Test page :
namespace first_portable_demo
{
class GreetingsPage : ContentPage
{
public GreetingsPage()
{
this.Content = new Label
{
Text = "Greetings, Xamarin"
};
//适配不同的平台
this.Padding = new Thickness(0, Device.OnPlatform(20,0,0),0,0);
}
}
}
ContentPage基类Page参考:
// Summary:
// A Xamarin.Forms.VisualElement that occupies most or all of the screen and
// contains a single child.
//
// Remarks:
// To be added.
public class Page : VisualElement, ILayout
{
//
// Summary:
// The space between the content of the Xamarin.Forms.Page and it‘s border.
//
// Remarks:
// To be added.
public Thickness Padding { get; set; }
其他UI Control位置调整方式: 对label的属性赋值 (Label继承与View)
public GreetingsPage()
{
this.Content = new Label
{
Text = "Greetings, Xamarin",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
}
使用Label自身属性特性:
this.Content = new Label
{
Text = "Greetings, Xamarin",
XAlign = TextAlignment.Center,
YAlign = TextAlignment.Center
};
更多Label属性参看Xamarin API,相应的属性也会提供内部设定好的类型/枚举,比如Font类
也可以操作Label的FormattedText属性
明天过一下基本的layout特性,Xamarin网站是不是本身就不稳定,经常看到IIS的错误提示,另外挂代理的话速度好一些
标签:style io os ar 使用 for sp on ad
原文地址:http://my.oschina.net/u/588339/blog/335229