【问题标题】:xamarin forms wp81 status bar background colorxamarin 表单 wp81 状态栏背景颜色
【发布时间】:2016-06-20 15:01:34
【问题描述】:

我正在开发一个 xamarin.forms 应用程序,在我的 windows phone 8.1 应用程序中,状态栏文本和背景颜色都是白色的。我尝试了所有样式,但没有任何效果。下面是我的代码

<x:Class="Sthotraani.WinPhone.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Sthotraani.WinPhone"
RequestedTheme="Light">
<Application.Resources>
    <Style TargetType="CommandBar">
        <Setter Property="Background" Value="#009688" />
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="FontSize" Value="12"/>
    </Style>

    <Style TargetType="ProgressBar" >
        <Setter Property="Foreground" Value="#F98F1C"/>
        <Setter Property="Height" Value="15"/>
    </Style>
    <Style TargetType="ProgressRing">
        <Setter Property="Foreground" Value="#F98F1C"/>
        <Setter Property="Height" Value="15"/>
    </Style>
</Application.Resources>

请帮帮我

【问题讨论】:

    标签: windows-phone-8.1 xamarin.forms statusbar


    【解决方案1】:

    在您的 App.xaml.cs 的 OnLaunched 方法中,您可以添加如下内容:

    var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
    statusBar.BackgroundColor = Windows.UI.Colors.Red;
    statusBar.BackgroundOpacity = 1;
    statusBar.ForegroundColor = Windows.UI.Colors.AntiqueWhite;
    

    【讨论】:

    • 我试过了,但没有运气:(,甚至添加了对行为 sdk 的引用
    • 你在方法的哪里添加它?它适用于我的 8.1 模拟器,所以我想知道为什么它不适合你。
    • 除了这一行,我保留了所有“statusBar.BackgroundOpacity = 1;”这会导致它吗?我会尽量把这个也放在晚上并更新你
    • 需要设置背景不透明度,否则颜色将保持/显示为黑色。
    • 今天试试 谢谢@Paul
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-26
    • 2015-06-01
    • 2015-03-16
    • 2019-11-20
    • 2018-04-10
    相关资源
    最近更新 更多