【发布时间】:2017-06-29 02:19:30
【问题描述】:
我正在使用 Xamarin Forms 开展一个项目。 我跟着 James Montemagno 的指南 https://blog.xamarin.com/material-design-for-your-xamarin-forms-android-apps/ 但我无法在通知栏和导航栏中获得相同的颜色
我正在像这样在 App XAML 中设置导航栏颜色
<ResourceDictionary>
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="#3b5998"/>
<Setter Property="BarTextColor" Value="White"/>
</Style>
</ResourceDictionary>
style.xml 和 values-v21/style.xml 与指南中的相同
<resources>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:windowBackground">@color/window_background</item>
<item name="windowActionModeOverlay">true</item>
</style>
</resources>
<resources>
<style name="MyTheme" parent="MyTheme.Base">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#3b5998</item>
</style>
</resources>
我在 values-v21/style.xml 中设置了statusBarColor,一个罕见的情况是,当我开始调试应用程序时,通知栏会获得我设置的颜色,但是当应用程序完成启动时,它恢复原来的颜色。
这是截图
我想将通知栏的颜色设置为与导航栏相同。
感谢你们的帮助!
【问题讨论】:
标签: xamarin xamarin.android xamarin.forms