【问题标题】:Xamarin Forms Shell Textcolor in Android Modal is not applied未应用 Android 模式中的 Xamarin Forms Shell Textcolor
【发布时间】:2020-12-09 23:49:33
【问题描述】:

我有一个 Xamarin Forms Shell 应用程序,我在其中以 Modal 形式打开多个页面。我想将条形文本颜色设置为选定的值,以便您实际上可以在黑暗和浅色主题中阅读文本。这是导航代码:

        return shell.Navigation.PushModalAsync(new NavigationPage(page)
        {
            BarBackgroundColor = Color.Transparent,
            BarTextColor = Color.Red
        });

(红色仅作为示例,以便清楚地看到颜色变化)。 在 iOS 上,颜色按预期调整:

但在 Android 上,颜色始终为白色:

【问题讨论】:

  • 我在我的demo中测试过,它在android中可以正常工作,你可以参考这个GIF。 imgur.com/a/dMwUFwf 我更新了我的演示给你,你可以在你的设备上测试它。 github.com/851265601/Xamarin.Android_ListviewSelect/blob/master/…
  • 请检查style.xml文件中是否有样式。
  • 我检查了您的样品,我可以确认标题颜色已调整。但不幸的是菜单按钮不是。
  • 我更新了答案,你可以参考一下。

标签: xamarin.forms


【解决方案1】:

打开您的styles.xml 文件,在您的Theme.AppCompat.DayNight.NoActionBar 样式中添加<item name="android:actionMenuTextColor">#ff0000</item>。

<style name="MyTheme.Base" parent="Theme.AppCompat.DayNight.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/orange</item>
    <item name="colorPrimaryDark">@color/orangeDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    
    <!--<item name="android:textColorPrimary">#fb2b32</item>-->
    <item name="android:actionMenuTextColor">#ff0000</item>
  </style>

这是运行截图。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-26
    • 2019-11-25
    • 2016-03-04
    • 1970-01-01
    • 1970-01-01
    • 2021-04-23
    • 1970-01-01
    相关资源
    最近更新 更多