zoukankan      html  css  js  c++  java
  • Xamarin.Forms 启动App时获取屏幕宽高

    启动App时获取屏幕宽高

    App.cs里面添加:
    public static double ScreenWidth;
    public static double ScreenHeight;
    Android下 MainActivity.cs里面添加:
    protected override void OnCreate(Bundle bundle)
    {
    TabLayoutResource = Resource.Layout.Tabbar;
    ToolbarResource = Resource.Layout.Toolbar;
     
    base.OnCreate(bundle);
     
    global::Xamarin.Forms.Forms.Init(this, bundle);
     
     
    var width = Resources.DisplayMetrics.WidthPixels;
    var height = Resources.DisplayMetrics.HeightPixels;
    var density = Resources.DisplayMetrics.Density; //
     
    App.ScreenWidth = width / density; //
    App.ScreenHeight = height / density; // 24 OnSizeAllocated
     
    LoadApplication(new App());
    }
    IOS下 AppDelegate.cs里面添加:
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
    global::Xamarin.Forms.Forms.Init();
     
    App.ScreenWidth = UIScreen.MainScreen.Bounds.Width; //
    App.ScreenHeight = UIScreen.MainScreen.Bounds.Height; //
     
    LoadApplication(new App());
     
    return base.FinishedLaunching(app, options);
    }
  • 相关阅读:
    【SignalR学习系列】3. SignalR实时高刷新率程序
    【SignalR学习系列】4. SignalR广播程序
    【SignalR学习系列】5. SignalR WPF程序
    python gb2312 转换为 utf-8
    爬虫 需要什么样的 CPU,内存 和带宽
    TypeError: sequence item 0: expected string, Tag found
    MySQL 数据的 截取,数据清洗
    MySQL (1366, "Incorrect string value: '\xF0\x9F\x8E\xAC\xE5\x89...' for column 'description' at row 1")
    微博爬虫 ----- 微博发布时间清洗
    ReferenceError: weakly-referenced object no longer exists Python kafka
  • 原文地址:https://www.cnblogs.com/xiaoa/p/8365531.html
Copyright © 2011-2022 走看看