colorPrimaryDark 似乎在 Xamarin.Android 中不起作用
colorPrimaryDark doesn't seem to work in Xamarin.Android
我在 Android Studio 中使用空 Activity 模板创建了一个应用程序。此模板包含一个非常简单的 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 主题规范,colorPrimaryDark 将更改 Lollipop 设备上的状态栏颜色。我用所有这些文件的确切内容创建了一个 Xamarin 项目。状态栏一直黑着。
我做错了什么?这在 Android Studio 中工作得很好。
我发现了问题。在项目属性中,我最初有以下内容:
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)
使用 SDK 版本编译的目标 Android 版本需要更改为特定的 API 级别。
我在 Android Studio 中使用空 Activity 模板创建了一个应用程序。此模板包含一个非常简单的 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 主题规范,colorPrimaryDark 将更改 Lollipop 设备上的状态栏颜色。我用所有这些文件的确切内容创建了一个 Xamarin 项目。状态栏一直黑着。
我做错了什么?这在 Android Studio 中工作得很好。
我发现了问题。在项目属性中,我最初有以下内容:
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)
使用 SDK 版本编译的目标 Android 版本需要更改为特定的 API 级别。