- Home
- Forum
- Xamarin.Forms
- Tap on sftextinputlayout
Tap on sftextinputlayout
Hi,
I have a form with SfTextInputLayout.
I try to have a textinputlayout, when I tap on it it shows a popup.
I tried a lot of different soultions but the tapped event is not working very well.
Then I tried Focused event on the textbox.
It works well, but how can I hide the keyboard when it s focused?
Thanks,
SIGN IN To post a reply.
5 Replies
1 reply marked as answer
AS
Anandraj Selvam
Syncfusion Team
June 23, 2020 07:30 AM UTC
Hi Alexis,
Greetings from the Syncfusion.
We have checked the reported query and you can achieve your requirement with Effects in Entry along with its custom renderer as per in below code snippet
[XAML]
|
<inputLayout:SfTextInputLayout Hint="Entry" ContainerType="Outlined" x:Name="inputlayout">
<Entry>
<Entry.Effects>
<effects:NoKeyboardEffect/>
</Entry.Effects>
</Entry>
</inputLayout:SfTextInputLayout> |
[NoKeyboardEffect.cs]
|
public class NoKeyboardEffect : RoutingEffect
{
public NoKeyboardEffect() : base("ControlSamples.Effects.NoKeyboardEffect")
{
}
} |
[NoKeyboardEffect_Droid.cs]
|
[assembly: ExportEffect(typeof(NoKeyboardEffect_Droid), nameof(NoKeyboardEffect))]
namespace ControlSamples.Droid.Effects
{
public class NoKeyboardEffect_Droid : PlatformEffect
{
protected override void OnAttached()
{
try
{
if (Control is EditText editText)
{
// cursor shown, but keyboard will not be displayed
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
{
editText.ShowSoftInputOnFocus = false;
}
else
{
editText.SetTextIsSelectable(true);
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"{nameof(NoKeyboardEffect_Droid)} failed to attached: {ex.Message}");
}
}
protected override void OnDetached()
{
}
}
} |
[NoKeyboardEffect_iOS.cs]
|
[assembly: ExportEffect(typeof(NoKeyboardEffect_iOS), nameof(NoKeyboardEffect))]
namespace ControlSamples.iOS.Effects
{
public class NoKeyboardEffect_iOS : PlatformEffect
{
protected override void OnAttached()
{
try
{
if (Control is UITextField textField)
{
// dummy view to override the soft keyboard
textField.InputView = new UIView();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"{nameof(NoKeyboardEffect)} failed to attached: {ex.Message}");
}
}
protected override void OnDetached()
{
}
}
} |
Please find the sample for your reference
Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/TextInputLayout1323337009
Regards,
Anand Raj S.
Marked as answer
AL
Alexis
June 23, 2020 05:38 PM UTC
Perfect thanks!
AS
Anandraj Selvam
Syncfusion Team
June 24, 2020 04:41 AM UTC
Hi Alexis,
Thanks for your update.
We are glad to hear that the solution works.
Please let us know if you need any further assistance.
Regards,
Anand Raj S.
JA
Javier
October 14, 2021 05:59 PM UTC
Hi,
I have tested the code with Android 4.4.2 and it´s not working (keyboard AOSP). Please could you tell me if it´s possible to fit it to this case?
Thanks in advance!
ET
Eswaran Thirugnanasambandam
Syncfusion Team
October 15, 2021 11:13 AM UTC
Hi Javier,
Greetings from Syncfusion.
We checked the reported problem in Android 4.4 with the API 19 version simulator. But we are unable to reproduce the problem from our side. We have prepared a video to show that keyboard is not visible when focusing the control on android 4.4 version. Please get the video from the below link.
Regards,
Eswaran.
SIGN IN To post a reply.
- 5 Replies
- 4 Participants
- Marked answer
-
AL Alexis
- Jun 22, 2020 10:08 AM UTC
- Oct 15, 2021 11:13 AM UTC