krisam
krisam

Reputation: 60

Customize DatePickerDialog Xamarin Android (Days Line)

I need to localize the letters of the days above the datepickerdialog in android. I already fully localized the application to the desired language. Changed the background etc. For some reason though, the letters of the days ain't changing.

I'm currently trying to alter the dialog via a CustomDatepickRenderer, but haven't found the right properties.

enter image description here

Upvotes: 0

Views: 167

Answers (1)

Wendy Zang - MSFT
Wendy Zang - MSFT

Reputation: 10978

You could use the custom renderer to set the current configuration.

Custom Renderer:

 [assembly: ExportRenderer(typeof(Xamarin.Forms.DatePicker), typeof(DatePickerDialogCustomRenderer))]
namespace App2.Droid
{
    class DatePickerDialogCustomRenderer : DatePickerRenderer
    {
    public DatePickerDialogCustomRenderer(Context context) : base(context)
    {
    }
    protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.DatePicker> e)
    {
        base.OnElementChanged(e);
        var locale = Locale.English;
        this.Control.TextLocale = locale;
        Resources.Configuration.SetLocale(locale);
    }     
   }
 }

The Language of the device is Chinese. Use the code to set the language of the Days Line to English.

Before:

enter image description here

After:

enter image description here

Upvotes: 1

Related Questions