UweReisewitz / XamarinAndroidEntry

Custom Entry for Xamarin Forms with full control over the virtual keyboard
MIT License
32 stars 6 forks source link

XamarinAndroidEntry

Custom Entry for Xamarin Forms with full control over the virtual keyboard

Update per 2020/12/06

It's now possible to set the vertical Alignment as well (use YAlign). The Sample app has been extended to show this feature.

Update per 2020/04/20

The previous version did not work on devices running Oreo (8.0/API 26) and above. It was necessary to set the property ShowSoftInputOnFocus on the native edittext to false. With that modification the solution works as expected on newer systems (up to 10.0 tested in simulator).

Why this sample?

Our app (part of our ERP system) runs on several different devices with Windows CE, iOS and Android. Most of the data entered into the system is scanned but some data (mostly quantities) has to be entered manually. Occasionally one has to enter some text as well.

That implies that in some fields you would like to get the virtual keyboard immediately while you want to get it in others only if needed.

In addition there are some devices that have a hardware keyboard. You don't want to get the keyboard there altogether. Of course you would like to have full control over this feature.

I have searched the internet quite a lot and found several samples but all of them lacked some functionality here and there.

So I decided to combine them into one sample control and an create a small app to showcase the control.

Features of the app:

Features of the control:

  1. Full control over the appearance and disappearance of the virtual keyboard
  2. A property to control if the keyboard should appear on focus automatically
  3. An additional object that gives an event when the keyboardheight changes (= when the keyboard appears and disappears). It allows you to modify your layout accordingly, if necessary.\ Please note that you don't need this if your layout is done like in the sample app. In that case Android does quite a good job to keep the important parts of your layout visible.

A few notes regarding ExtendedEntry:

Some key lines in the code:

ExtendedEntryRenderer.OnElementChanged:

App.OnStart:

Additions to Entry:

Object SoftwareKeyboardService: