Hello,
Welcome to our Microsoft Q&A platform!
You can create a Custom renderer
to hide the keyboard when Entry
get the focus.
Firstly, Create an class to extend the Entry
in shared code.
public class MyEntryHideKeyboard:Entry
{
}
Then, Implement the custom renderer in the android platform.
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(MyEntryHideKeyboard), typeof(MyEntryRenderer))]
namespace App141.Droid
{
class MyEntryRenderer : EntryRenderer
{
public MyEntryRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
EditText editText= Control as EditText;
editText.InputType = Android.Text.InputTypes.Null;
}
}
}
}
In the end, we can use it in the xml.
<app141:MyEntryHideKeyboard x:Name="MyEntry"></app141:MyEntryHideKeyboard>
When you use code to get focus in the OnAppearing
method. This Keybord will not show, but you focus still exist.
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
MyEntry.Focus();
}
}
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.