How to reduce the height of keyboard using custom renderer in xamarin forms?

judsonabrahamjudsonabraham USMember ✭✭✭

I want to customize my Keyboard using custom renderer in Xamarin forms. I want to reduce the height of keyboard and add a tab key if possible. I don't know what function will help me to do that. This is my custom renderer code.

    protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
            {
                base.OnElementChanged(e);

                if (Control != null)
                {
                    Control.InputScope = Element.Keyboard.ToInputScope();
                    InputScope inputScope = new InputScope();
                    inputScope.Names.Add(new InputScopeName
                    {
                        NameValue = InputScopeNameValue.NumericPin // For 0-9 only
                                                                   //NameValue = InputScopeNameValue.Number // for numerics, but allowing other characters
                                                                   //NameValue = InputScopeNameValue.CurrencyAmountAndSymbol // For monetary values
                    });


                }
            }

I want this to be done only for UWP. Any suggestions?

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    You don't.

    Keyboard (at least on android) is not only its own app with its only layout XML and so on... But it completely sealed off from other processes.

    The reason is simple: Security. No OS maker is going to let some John Doe program start messing around with, altering and capturing keystrokes of the OS keyboard. That's a theft identity nightmare in the making.

  • JohnHardmanJohnHardman GBUniversity mod

    @judsonabraham

    As you are probably aware, there is more than one soft keyboard available when using UWP, there is the On-Screen Keyboard (OSK), and the Soft Input Panel (SIP, a.k.a. Touch Panel). AFAIK, the OSK always has a tab button. However, the SIP changes according to the InputScope. I think it is a major oversight that there seems to be no way of adding a tab key to the minimalist keypad when InputScope contains InputScopeNameValue.NumericPin (or various other options too). However, AFAIK, that's the way it is (I'll be happy to be corrected if I'm wrong!). The user does have the ability to switch the SIP to a different format which does have a tab button by using the button at the top left of the SIP, but that's very user-unfriendly.

    So, the easiest option when entering something containing digits (but not decimal points etc), with a tab key, and at a smaller size than the SIP, is to avoid Xamarin.Forms.Entry (which I assume you are using) and to build your own View, that when focused builds its own soft keyboard (possibly using Rg.Plugins.Popup). If you know it's just going to be four digits or six digits the UI can be very simple, rather than trying to replicate Entry. Many online banking/investment apps already do this, even on iOS and Android, so you won't be the first.

  • judsonabrahamjudsonabraham USMember ✭✭✭

    @JohnHardman said:
    @judsonabraham

    As you are probably aware, there is more than one soft keyboard available when using UWP, there is the On-Screen Keyboard (OSK), and the Soft Input Panel (SIP, a.k.a. Touch Panel). AFAIK, the OSK always has a tab button. However, the SIP changes according to the InputScope. I think it is a major oversight that there seems to be no way of adding a tab key to the minimalist keypad when InputScope contains InputScopeNameValue.NumericPin (or various other options too). However, AFAIK, that's the way it is (I'll be happy to be corrected if I'm wrong!). The user does have the ability to switch the SIP to a different format which does have a tab button by using the button at the top left of the SIP, but that's very user-unfriendly.

    So, the easiest option when entering something containing digits (but not decimal points etc), with a tab key, and at a smaller size than the SIP, is to avoid Xamarin.Forms.Entry (which I assume you are using) and to build your own View, that when focused builds its own soft keyboard (possibly using Rg.Plugins.Popup). If you know it's just going to be four digits or six digits the UI can be very simple, rather than trying to replicate Entry. Many online banking/investment apps already do this, even on iOS and Android, so you won't be the first.

    @JohnHardman any clue how to reduce the height of keyboard?

  • judsonabrahamjudsonabraham USMember ✭✭✭

    Is it possible to show Onscreen keyboard instead of soft input panel in xamarin forms?

  • JohnHardmanJohnHardman GBUniversity mod

    @judsonabraham said:
    @JohnHardman any clue how to reduce the height of keyboard?

    See second paragraph of my previous post.

  • judsonabrahamjudsonabraham USMember ✭✭✭

    @JohnHardman Is it possible using custom renderer for the entry rather than popup?

  • JohnHardmanJohnHardman GBUniversity mod

    @judsonabraham said:
    Is it possible to show Onscreen keyboard instead of soft input panel in xamarin forms?

    I haven't tried it, but you could try using Process.Start to open osk.exe . If security/permissioning doesn't get in the way, it might work. However, given that you want a small keyboard, you almost certainly wont want to use the OSK.

  • JohnHardmanJohnHardman GBUniversity mod

    @judsonabraham said:
    @JohnHardman Is it possible using custom renderer for the entry rather than popup?

    Most things are possible if you are willing to spend enough time developing them. Using a custom renderer that replaces the FormsTextBox would be possible. However, you'd still need to use a pop-up. Keeping the FormsTextBox and using a custom renderer to replace the SIP is not, AFAIK, possible.

Sign In or Register to comment.