1
votes

By default, it seems that the background is white and the labels are grey. This looks bad. I would change the labels' colour to complete black.

But I do not want to set the TextColor individually. There must be a way to change the default label color at once. I looked into the shared module, but I cannot find anything. The sytles.xml in the Android project does not have the grey colour. Where can I find it?

2
there are two want to set this one is create style and set it and another way create label render and set textcolor property. - Ziyad Godil

2 Answers

5
votes

You can do this many ways but simplest way is using custom control

public class MyLabel : Label
{
  public MyLabel ()
  {
    BackgroundColor = Color.Gray;
  }
}

You can use using this :

<MyLabel Text="This is testing" />

Re: https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/introduction/

OR

Set style in App.xaml

<Application.Resources>
         <ResourceDictionary>
            <Style TargetType="Label">
                <Setter Property="TextColor" Value="Gray" />
            </Style>
        </ResourceDictionary>
    </Application.Resources>
4
votes

If you want to change TextColor of all label then you can do it from implicit style like this:

<Style TargetType="Label">
    <Setter Property="TextColor" Value="Black" />
</Style>

And add this to resource dictionary of App.xaml