Joh*_*ore 3 xamarin xamarin.forms
引用在...处找到的代码突出显示地图上的路线
他们展示...
var customMap = new CustomMap
{
WidthRequest = App.ScreenWidth
};
Run Code Online (Sandbox Code Playgroud)
App.ScreenWidth
不再可用.它被取代了Application.Current.MainPage.Width
吗?
在该演示中,App.ScreenWidth
并且App.ScreenHeight
是在定义静态变量App
类,并分配到native
项目:
iOS应用项目:
App.ScreenWidth = UIScreen.MainScreen.Bounds.Width;
App.ScreenHeight = UIScreen.MainScreen.Bounds.Height
Run Code Online (Sandbox Code Playgroud)
Android应用程序项目:
App.ScreenWidth = (width - 0.5f) / density;
App.ScreenHeight = (height - 0.5f) / density;
Run Code Online (Sandbox Code Playgroud)
参考:https://github.com/xamarin/recipes/search? p = 2& q = ScreenWidth & utf8 = ✓
在PCL中获取设备高度和宽度的最简单,最准确的方法:
using Xamarin.Forms;
namespace ABC
{
public class MyPage : ContentPage
{
private double _width;
private double _height;
public MyPage()
{
Content = new Label
{
WidthRequest = _width,
Text = "Welcome to Xamarin.Forms!"
};
}
protected override void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width, height);
_width = width;
_height = height;
}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2054 次 |
最近记录: |