Changing the default dark Android theme to white in Xamarin.Forms?
29,727
Solution 1
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" />
Solution 2
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.
Author by
SteAp
Fiddling around with Flutter. Writing Frog (spare-time project). Profile image: Please don't copy my painting.
Updated on February 25, 2020Comments
-
SteAp over 4 years
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?
-
SteAp about 10 yearsGreat! But then another question comes up: stackoverflow.com/questions/24173718/…
-
MelloG over 9 yearsAnd how would it behave on the other application types, considering that forms is designed to be for Android, iOS and Windows Phone
-
ad1Dima over 9 years@MelloG it has only android effect and no effect on other platforms.
-
JustAMartin almost 8 yearsAnd what if I don't want to enforce the theme but instead be consistent with current Android theme on user's device? Is there any way to say to my app (and especially Xamarin.Forms app) to sync to the system theme?
-
ad1Dima almost 8 years@JustAMartin not tested, but Theme.DeviceDefault should be your case developer.android.com/reference/android/…