2

The status bar and the screen moves up completely when the keyboard popsUp in xamarin forms android and the EditText field is in the bottom of the screen. I tried using

WindowSoftInputMode = SoftInput.AdjustPan 

and

WindowSoftInputMode = SoftInput.AdjustResize

But unfortunately both are not working,i also clubbed both From a blog post i read putting

Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);

and

if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
{
    Window.DecorView.SystemUiVisibility = 0;
    var statusBarHeightInfo = typeof(FormsAppCompatActivity).GetField("_statusBarHeight", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
    statusBarHeightInfo.SetValue(this, 0);
    Window.SetStatusBarColor(new Android.Graphics.Color(0,0,0, 255)); // Change color as required.
 }

after launch application is an alternative, but unfortunately this also failed. Any other option available?

George Thomas
  • 4,566
  • 5
  • 30
  • 65

1 Answers1

3

Its a bug in Xamarin. I used following code in mainActivity

    if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
    {
                    Window.DecorView.SystemUiVisibility = 0;
                    var statusBarHeightInfo = typeof(FormsAppCompatActivity).GetField("_statusBarHeight", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                    statusBarHeightInfo.SetValue(this, 50);
    }

And used

Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);

The problem was it wont work if you forcefully hide the title bar

Forms.SetTitleBarVisibility(AndroidTitleBarVisibility.Never);

I commented out this code and the issue was solved. But due to resize property i faced lot of issue since i have designed screens with Grid and star value which caused many unwanted issues. So i am not going to use this method sadly. :(

George Thomas
  • 4,566
  • 5
  • 30
  • 65