Forum Cross Platform with Xamarin


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Showing keyboard without creating control


I'm looking for a way to show keyboard in iOS and Android app.
What I want to do is to show keyboard at some point without creating any control (EditText etc.).
There is a method on Windows 8.1/Windows 10 platform which does exactly what I need:


but I can't find a way to do so on other platforms. Could anybody help me?

P.S. What I have now is super-lame solution by showing Textbox 10 000 pixels on the right and focusing it when needed.

Best Answers


  • Thank you @Yksh.Leo - that worked for Android :)

    Do you have perhaps solution for iOS?

  • Wow, that's a lot of code for such a simple task:P

    BTW Apple should just create a single method for this...

  • MommMomm USMember ✭✭✭



            var window= UIApplication.SharedApplication.KeyWindow;
            UIView mainView = window.RootViewController.View;


            var window= UIApplication.SharedApplication.KeyWindow;
            UIView mainView = window.RootViewController.View;
  • adamkempadamkemp USInsider, Developer Group Leader mod

    I've never heard of FindAndBecomeFirstResponder, and google shows zero results. I don't think that function exists. Maybe it's something you wrote. If I had to guess I would say it looks for a subview that can become first responder and makes it the first responder. I'm not sure that's the best way to do this. Giving focus to some random view will give you some random keyboard, and typing in that keyboard will do some random thing. You don't want that.

    Unfortunately, on iOS the system requires that some view have focus in order to show the software keyboard. You just have to do that. In order to show the keyboard without appearing to have focus you have to make a view that's invisible somehow and give it focus. Then you can control the keyboard settings and respond to the keyboard input through that hidden view.

    What exactly are you doing with the keyboard in this situation?

  • YkshLeoYkshLeo USMember ✭✭✭✭
    edited October 2015

    I don't know about FindAndBecomeFirstResponder or FindAndResignFirstResponder.

    There is a BecomeFirstResponder method, which just request an object to become the first responder.


    ResignFirstResponder method, and is called when the UIResponder has been asked to resign its first responder status.

    @Momm, it will be helpful if you explain those codes.

  • MommMomm USMember ✭✭✭
    edited October 2015

    Yes, I was wrong and got confused with FindAndBecomeFirstResponder and BecomeFirstResponder, and FindAndResignFirstResponder and ResignFirstResponder, but basically they are implemented the way that Adam suggested, you will have a foreach in mainView.Subviews recursivelly and then call BecomeFirstResponder in the desired view or ResignFirstResponder checking if it is the first responder.

  • adamkempadamkemp USInsider, Developer Group Leader mod

    Yeah, that's a terrible idea for the reasons I gave above. You will get an arbitrary keyboard (some views want a numeric keyboard, others want a URL keyboard, etc.), and typing in that keyboard will do some random thing (your input will actually be going to some random view). I can't think of a case where it makes sense to do that.

  • MommMomm USMember ✭✭✭

    In our case, we didn't force to a random view, we forced to the SearchBar, so it worked well, no side effects.

  • adamkempadamkemp USInsider, Developer Group Leader mod

    Until someone introduces a focusable view that is found before the search field, in which case it will do the wrong thing. If you want the search field to have focus then you should be going directly to the search field and giving it focus. Using these FindAndBecomeFirstResponder methods and hoping it finds the view you actually want to give focus is going to lead to problems eventually.

Sign In or Register to comment.