38

Xamarin.Forms 确实会生成一个灰色的 Android应用程序。我想在 Android 中有一个浅色/白色主题(就像在 iOS 目标中一样)。

是否存在简单的切换方法?

4

3 回答 3

74

您可以将 Theme 参数放入主要活动的 ApplicationAttribute

像这样

[assembly: Application(Icon = "@drawable/Icon", Theme = "@android:style/Theme.Holo.Light")]

或者你可以把这个字符串放到 AndroidManifest.xml

<application android:theme="@android:style/Theme.Holo.Light" />
于 2014-06-11T03:48:31.037 回答
8

ad1Dima 的回答让我大部分时间都在那里,但我发现在我的环境中我需要一些稍微不同的东西。这就是我放入“MainActivity.cs”文件以更改主题的内容。

    [Activity( Theme="@android:style/Theme.Holo.Light",Label = "HealthTechnologies", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : AndroidActivity

请注意,这里唯一的新功能是添加了“Theme=...”。其他所有内容都已在 MainActivity.cs 文件中。

于 2014-11-27T05:26:17.960 回答
0

打开android清单文件app_name->Properties->AndroidManifest.xml

现在在里面添加这一行<manifest>

<manifest>
    ...
    <application android:theme="@android:style/Theme.DeviceDefault.Light"></application>
    ...
</manifest>
于 2018-02-24T05:45:42.583 回答