How to override Keyboard culture on Numeric Entry?

batmacibatmaci DEMember ✭✭✭✭✭
edited August 15 in Xamarin.Forms

General overriding culture solution works for me in Android just like provided here

public void SetLocale(CultureInfo ci)
    {
        Thread.CurrentThread.CurrentCulture = ci;
        Thread.CurrentThread.CurrentUICulture = ci;

    }

but there is case when Phone culture is different than App culture.
So if I set my phone as en-us and my app overrides is with de-de German.
and I have a numeric entry where I want to enter decimal values, I expect to have comma in the keyboard.
but keyboard grays out comma and display only dot. which means that culture is en-us for they keyboard. you can give it a try in a sample app.
Question is how to override keyboard culture?

Ps, I am actually not sure if that is a new bug xamarin introduced because I have this going long time and I believe that it was working for me in earlier versions or I overlooked this scenario. I am using the latest xamarin forms and android update.

Answers

  • Xami3Xami3 PKMember, University ✭✭✭

    @batmaci hay! which version of XF you are using?

  • batmacibatmaci DEMember ✭✭✭✭✭
    edited August 15
    Latest version but i think that this is known issue mostly can be reproducible with samsung phones. Like indicated here

    https://stackoverflow.com/q/41622354/492482
  • JarvanJarvan Member, Xamarin Team Xamurai
    edited August 15

    Question is how to override keyboard culture?

    You may need to create a custom keyboard. See the tutorial:

  • batmacibatmaci DEMember ✭✭✭✭✭

    @Jarvan i wonder is that a bug in xamarin or samsung phones? why for numeric it displays only dot as decimal separator? but surprisingly it occurs only on samsung phones keyboard issue. i tested on sony and fire tablet and it works with comma and dot.

  • JarvanJarvan Member, Xamarin Team Xamurai

    It should be caused by different internal settings of the Samsung device.

  • batmacibatmaci DEMember ✭✭✭✭✭

    @Jarvan I dont believe that this is a samsung problem. actually samsung does different than other manufacturers.

    • other manufacturers: they display dot and comma in their keyboard regardless of culture and let the user to handle decimal text input in their code.
    • samsung: they display dot or comma based on the culture. this culture I dont know what? Is it culture of app, probably no. is it culture of text input, probably. but samsung keyboard does that and Xamarin.android doesnt handle it. I tested with java written app, it works just fine. Workaround like this one below, isn't a solution https://github.com/xamarin/Xamarin.Forms/issues/1898#issuecomment-432539426
      this only changes skin of the keyboard replacing dot with comma but when you press on comma, it still writes dot into the entry and you should use string replace dot to comma. Dirty workaround.
      I believe that xamarin has a bug here. it just doesnt appear on other manufacturers because they dont restrict like samsung,
Sign In or Register to comment.