'How to disable emojis from android keyboard in xamarin forms?
I am working on xamarin forms. I am creating app for android. I need to disable the emojis from android keyboard from c#. How I can do this in xamarin forms?
Solution 1:[1]
Use this code to remove the Emoji in the Keyboard. <Entry Keyboard="Email" />
Or Please use this Custom Renderer to achieve this.
Create Custom Renderer for Entry
Create a class in Shared or PCL Project.
public class MyEntry:Entry
{
}
Use this Custom Code in XAML like below code
<custom:MyEntry x:Name="myEntry" HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"/>
Create a Class for Custom renderer in Android Project
[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace YourNameSpace
{
public class MyEntryRenderer : EntryRenderer
{
public MyEntryRenderer(Android.Content.Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.ImeOptions = Android.Views.InputMethods.ImeAction.Done;
Control.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationVisiblePassword| Android.Text.InputTypes.TextFlagMultiLine;
Control.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
}
}
}
}
Solution 2:[2]
Create Custom Renderer for Entry
Create a class in Shared or PCL Project.
public class MyEntry:Entry
{
}
Use this Custom Code in XAML like below code
<custom:MyEntry x:Name="myEntry" HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"/>
Create a Class for Custom renderer in Android Project
[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace YourNameSpace
{
public class MyEntryRenderer : EntryRenderer
{
public MyEntryRenderer(Android.Content.Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.ImeOptions = Android.Views.InputMethods.ImeAction.Done;
Control.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationVisiblePassword| Android.Text.InputTypes.TextFlagMultiLine;
Control.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
}
}
}
}
Solution 3:[3]
You can set the Keyboard type to text in Entry.
<Entry Keyboard="Text" />
Emoji's will be shown when the Keyboard type is
<Entry Keyboard="Chat" />
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ângelo Polotto |
| Solution 2 | Gladis Wilson |
| Solution 3 |

