Is there any way to check if keyboard is open or not in Xamarin Forms? Are there any events getting fired when the keyboard opens or closes? If so, where can I find an example of it?
相关问题
- Custom controls disabled. There was an internal is
- How to implement only emoji keyboard for Entry?
- Error:Xamarin.Forms targets have been imported mul
- Detection of swiping on a normal Android Activity
- HttpClient not accepting Authorization headers (40
相关文章
- Xamarin form MessagingCenter Unsubscribe is not wo
- The type initializer for 'SQLite.SQLiteConnect
- How to use native C++ libraries in Mono for Androi
- Xamarin build error: defining a default interface
- Xamarin Android Player Error when attempting to fi
- How to change the Back Button Text on Xamarin.Form
- Can Android Studio and Visual Studio safely share
- Android Webview cannot render the pdf sometimes an
I don't believe that there's a
Xamarin.Forms
way of doing it. Anyway, for the different platforms (at least Android and iOS) there is a way to achieve what you want.Android
Under android there is
InputMethodManager
class. You can obtain it from your activityNow you can check if the keyboard is shown with
According to this article on CodeProject you can use a class derived from
IOnGlobalLayoutListener
to listen to global layout events. When this event has fired, you can use the code above to check, if the layout has been changed due to the keyboard popping up.iOS
Under iOS you may use
UIKeyboard
class which allows you to observe theDidShowNotification
(see here).similarly you can observe
DidHideNotification
(and some others - see here).Xamarin.Forms
To implement the keyboard-notification in your Xamarin.Forms the easiest way will be to implement platform dependencies which are resolved with the
DependencyService
. To do this, you'll first have to introduce an interface for the platform service.In your platform specific projects you'll have to implement the functionality in a platform specific way. See the following code section for iOS implementation
The
Xamarin.Forms.Dependency
makes the class visible to theDependencyService
. See the following code for Android implementationIn your Xamarin.Forms app you can now obtain an instance of the correct implementation of
IKeyboardService
with