Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the default dark Android theme to white in Xamarin.Forms?

Xamarin.Forms does generate a greyish Android application. I'd like to have a light / white theme in Android (like in the iOS target).

Does a simple way to switch exist?

like image 766
SteAp Avatar asked Jun 08 '14 01:06

SteAp


People also ask

How do I turn off dark mode in xamarin Android?

If you want to disable the dark mode for your entire application you can add the key below in the info. plist: <key>UIUserInterfaceStyle</key> <string>Light</string>

How does xamarin form handle dark mode?

Set the current user themeDark; In this example, the application is set to use the theme defined for the system dark mode, regardless of which system theme is currently operational. Set the UserAppTheme property to OSAppTheme. Unspecified to default to the operational system theme.

What is Resource Dictionary in xamarin forms?

A ResourceDictionary is a repository for resources that are used by a Xamarin. Forms application. Typical resources that are stored in a ResourceDictionary include styles, control templates, data templates, colors, and converters.


2 Answers

You can put Theme parameter to ApplicationAttribute of your main activity

like this

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

Or you can put this string to AndroidManifest.xml

<application android:theme="@android:style/Theme.Holo.Light" /> 
like image 154
ad1Dima Avatar answered Nov 04 '22 23:11

ad1Dima


The answer from ad1Dima got me most of the way there, but I found that in my environment I needed something slightly different. This is what I put in my 'MainActivity.cs' file to change the theme.

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

Note that the only thing that was new here was the addition of the 'Theme=...'. Everything else was already in the MainActivity.cs file.

like image 20
Rick Arthur Avatar answered Nov 04 '22 23:11

Rick Arthur