首页 文章

更改Xamarin表单Android导航页面颜色(按钮和背面)

提问于
浏览
0

我试图在我的Xamarin Forms应用程序中更改导航页面的外观 . 我想要一个蓝色条,所有文字都是白色的 . 我已经能够设置NavigationPage的属性,但我无法设置条形按钮项或后退按钮的颜色 . 以下是2个截图,说明了我的应用目前的状态:

Screenshot1

Screenshot2

黑色看起来很糟糕,这个需要是白色的 . 现在,我看看如何改变这些颜色,但似乎没有任何效果 .

我目前已尝试过这些帖子中提供的解决方案:

这是非常荒谬的点,我在iOS上用不到5分钟的时间实现了这一点,我花了一天的时间来试图让一些文字变白......

如何将导航栏上的文本设置为白色,iOS中的一个示例(没有我的代码)是 self.navigationBar.tintColour =' White' ,这将在导航栏上的任何内容上应用白色 . 正是我想要的!

谢谢,这是我的styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MainTheme" parent="MainTheme.Base">
    </style>
    <!-- Base theme applied no matter what API -->
    <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
        <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
        <item name="windowNoTitle">true</item>
        <!--We will be using the toolbar so no need to show ActionBar-->
        <item name="windowActionBar">false</item>
        <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
        <!-- colorPrimary is used for the default action bar background -->
        <item name="colorPrimary">#2196F3</item>
        <!-- colorPrimaryDark is used for the status bar -->
        <item name="colorPrimaryDark">#1976D2</item>
        <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
        <item name="colorAccent">#FF4081</item>
        <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
        <item name="windowActionModeOverlay">true</item>
        <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>

        <item name="android:actionBarPopupTheme">@style/CustomActionBarPopupTheme</item>
    </style>
    <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorAccent">#cbff34</item>
    </style>

    <style name="CustomActionBarPopupTheme" parent="android:ThemeOverlay.Material.Light">
        <item name="android:colorBackground">#cbff34</item>
        <item name="android:textColor">#cbff34</item>
    </style>

</resources>

1 回答

  • 0

    您可以为styles.xml添加样式,

    <style name="ToolbarStyle" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize color of navigation drawer icon and back arrow -->
        <item name="colorControlNormal">#ffffff</item>
      </style>
    

    并将此作为主题添加到工具栏layout.axml中的工具栏中(在布局文件夹下的android项目中),请在下面查看 android:theme="@style/ToolbarStyle"

相关问题