zoukankan      html  css  js  c++  java
  • xamarin 手机顶部状态栏

       修改显示xamarin开发的App的手机顶部状态栏,

        步骤一:在项目UWP上的“引用”里右键“添加引用”,选择->Universal Windows->Windows Mobile Extensions for the UWP 选项,添加引用,

        步骤二:在App.xaml.cs 类OnLaunchedl里添加如下代码:   

    if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) {//判断是否有状态栏,PC无状态栏会出错
        StatusBar bar = StatusBar.GetForCurrentView();  
        bar.ForegroundColor = Colors.White;
        Color bgColor = Color.FromArgb(255, 54, 188, 99);
        bar.BackgroundColor = bgColor;
        bar.BackgroundOpacity = 1d;//1表示不透明 d:double
    }

       步骤三: 在App.xaml.cs 类OnSuspending里添加:

       //全屏设置

        ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

        总结:其中的bar.BackgroundColor可以设置为自己想要的颜色,也可注释掉,不设置颜色,不设置颜色是背景色为明暗两种主题的颜色,即黑底白字或者白底黑字两种。即使设置为各种颜色主题,但是顶部状态栏只有这两种。

        

  • 相关阅读:
    树链剖分学习笔记(未完)
    VI 配置文件(略全)
    linux之awk
    指针之基础篇
    linux之sed
    sqlplus命令手册
    Leetcode复习: 堆和栈
    leetcode 的shell部分4道题整理
    Regular Expression Matching [leetcode]
    深入浅出JAVA
  • 原文地址:https://www.cnblogs.com/zuimengaitianya/p/5895525.html
Copyright © 2011-2022 走看看