0

I need to increase the distance between the soft-keyboard and the editor in the UI. Currently, the keyboard overlaps the editor bottom part.

Screenshot adding below:

enter image description here

Is there any solution for this?

Sreejith Sree
  • 3,055
  • 4
  • 36
  • 105

2 Answers2

1

Try the below code it will be help you.

In Xamarin Android Project

    public class MainActivity 
    {
    protected override void OnCreate(Bundle savedInstanceState)
     {

      Window.SetSoftInputMode(Android.Views.SoftInput.AdjustUnspecified);
     }
}

or in AndroidManifest.xml

<activity android:name=".myActivity"
 android:label="@string/app_name"
 android:screenOrientation="sensorPortrait"
 android:windowSoftInputMode="adjustPan"/>

check the java code on given link- KeyboardSize

Pratius Dubey
  • 673
  • 6
  • 19
  • I will try this and update you. I need this feature for ios also, is there solution for ios part? – Sreejith Sree Nov 26 '18 at 12:10
  • In IOS it will be not giving a same layout. If you are facing same issues in IOS check the this link -https://forums.xamarin.com/discussion/30336/popup-keyboard-hides-parts-of-the-ui-rather-than-resizing – Pratius Dubey Nov 26 '18 at 12:17
  • I tried your code on the android part, but no change in the gap between keyboard and editor, still they are touching. – Sreejith Sree Nov 27 '18 at 07:09
0

Xamarin forms: How to increase the distance between keyboard and editor

You could implement this feature by add paddingBottom property for your Edior.

Here is an example, add the paddingBottom property in your EditorRenderer:

public class CustomEditorRenderer : EditorRenderer
{
    public CustomEditorRenderer(Context context) : base(context)
    {
    }

    protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Editor> e)
    {
        base.OnElementChanged(e);

        if (Control == null)

            return;

        //Control.Background = new ColorDrawable(Android.Graphics.Color.Transparent);
        //Control.Background = null;

        float scale = Context.Resources.DisplayMetrics.Density;
        int dpAsPixels = (int)(50 * scale + 0.5f);
        Control.SetPadding(0, 0, 0, dpAsPixels);
    }
}

Effect: Original space, Custom space.

York Shen
  • 9,014
  • 1
  • 16
  • 40