【问题标题】:colorPrimaryDark doesn't seem to work in Xamarin.AndroidcolorPrimaryDark 似乎在 Xamarin.Android 中不起作用
【发布时间】:2023-03-24 15:50:01
【问题描述】:

我使用 Empty Activity 模板在 Android Studio 中创建了一个应用。此模板包含一个非常简单的 Activity,其布局只有一个 TextView。 它包含的内容之一是定义简单主题的 styles.xml / colors.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>

  <!-- Base application theme. -->
  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
  </style>

</resources>

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <color name="colorPrimary">#3F51B5</color>
  <color name="colorPrimaryDark">#303F9F</color>
  <color name="colorAccent">#FF4081</color>
</resources>

根据 Material Theme 规范,colorPrimaryDark 将更改 Lollipop 设备上的状态栏颜色。我创建了一个包含所有这些文件的确切内容的 Xamarin 项目。状态栏保持黑色。

我做错了什么?这在 Android Studio 中运行良好。

【问题讨论】:

    标签: xamarin xamarin.android


    【解决方案1】:

    我发现了问题。在项目属性中,我最初有以下内容:

    Compile using Android version: Use Latest Platform (Android 6.0 (Marshmallow))
    Minimum Android to target: Android 4.4 (API Level 19 - Kit Kat)
    Target Android version: Use Compile using SDK version
    

    我改成:

    Compile using Android version: Use Latest Platform (Android 6.0 (Marshmallow))
    Minimum Android to target: Android 4.4 (API Level 19 - Kit Kat)
    Target Android version: Android 6.0 (API Level 23 - Marshmallow)
    

    Compile Using SDK Version 上的目标 Android 版本需要更改为特定的 API 级别。

    【讨论】:

      猜你喜欢
      • 2017-08-31
      • 2015-05-20
      • 1970-01-01
      • 2019-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多