How to hide keyboard when focusing Entry

KayKuoKayKuo Member ✭✭✭

I have a Xamarin.forms project, I have a page with an Entry control, I want to hide the keyboard when the Entry gets the focus ,because it is for scanning barcode labels, how can I achieve that?
The following code can implement hidden keyboard, but the keyboard occasionally shows,especially when the entry is empty.
How can I avoid it?thanks
here is my caode :
Control.InputType = 0;
Control.ShowSoftInputOnFocus = false;
InputMethodManager inputMethodManager = Control.Context.GetSystemService(Context.InputMethodService) as InputMethodManager;
inputMethodManager?.HideSoftInputFromWindow(Control.WindowToken, HideSoftInputFlags.None);


  • Have you tried putting your view inside ScrollView?

    //...Your code
  • KayKuoKayKuo Member ✭✭✭

    @LuisDavidDelaCruz sorry,Maybe I don't quite understand what you mean. :'(

  • @KayKuo Use ScrollView
    Like in the example:


    <BoxView BackgroundColor="Red" HeightRequest="600" WidthRequest="150" />
    <Entry />


  • KayKuoKayKuo Member ✭✭✭

    thank you,i will try this

  • BushbertBushbert Member ✭✭✭

    I think @LuisDavidDelaCruz misunderstood your question.

    Wrapping it in a scrollview might help if you were wanting to avoid the keyboard overlapping the entry control.

    I can think of a three options.

    1. An entry control is designed to capture text, so it will display a keyboard by default. You could use a custom renderer.

    2. Rather than use an entry why not just use a button. When the user presses the button launch your bar scanning code and set the value to the text property of the button?

    3. Disable the entry control and create a tap event on another container.

              Placeholder="Can Barcode"
  • JohnHardmanJohnHardman GBUniversity mod

    @KayKuo - Is this using a scanner that populates the Entry with the barcode's textual equivalent?

  • KayKuoKayKuo Member ✭✭✭

    @Bushbert thank you,but we don't need any buttons,when the entry get focus,The scanned data will be filled in entry automatically,so i need to hide the soft keyboard

  • KayKuoKayKuo Member ✭✭✭
  • KayKuoKayKuo Member ✭✭✭

    @LuisDavidDelaCruz thank you,But this is not what I need

Sign In or Register to comment.