Hi!
I am having some issues with Xamarin Forms and screen orientation changes. When rotating the screen from landscape to portrait with the keyboard up, the view is rendered incorrectly.
Here is a screenshort of what it looks like:
What I want is the editor to be at the bottom of the view at all times. If it gets focus, and the keyboard shows up, I want the editor to be right above the keyboard. This is working correctly if the screen is not rotated. But I need my app to support dynamic screen orientation changes.
I am using a custom renderer for the editor to make the keyboard more simple. I deactivate suggestions, voice input, and landscape fullscreen. This seems to be the reason it is incorrectly rendered. Am I doing something wrong with my layouts or this a bug in Xamarin/Android?
Steps to reproduce (using the code below):
- Focus the input field so that the soft keyboard shows up
- Rotate the screen to landscape mode with the keyboard still up
- Rotate the screen back to portrait mode, this is where the view is incorrectly rendered
Here is the application code (not the real app, but everything needed to reproduce the issue):
using System;
using Xamarin.Forms;
namespace BuggyOrientation
{
class SimpleEditor : Editor {}
public class App : Application
{
public App ()
{
MainPage = new ContentPage {
Content = new StackLayout {
VerticalOptions = LayoutOptions.FillAndExpand,
Children = {
new BoxView {
VerticalOptions = LayoutOptions.FillAndExpand,
Color = Color.Red
},
new SimpleEditor()
}
}
};
}
}
}
... and here is the custom renderer for SimpleEditor:
using System;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Android.Views;
using Android.Views.InputMethods;
using Android.Text;
using BuggyOrientation;
using BuggyOrientation.Droid;
[assembly: ExportRenderer (typeof(SimpleEditor), typeof(SimpleEditorRenderer_Droid))]
namespace BuggyOrientation.Droid
{
public class SimpleEditorRenderer_Droid : EditorRenderer
{
protected override void OnElementChanged (ElementChangedEventArgs<Editor> e)
{
base.OnElementChanged (e);
if (Control != null) {
Control.InputType = Control.InputType | InputTypes.TextFlagNoSuggestions;
Control.PrivateImeOptions = "nm";
Control.ImeOptions = Control.ImeOptions | (ImeAction)0x02000000; // IME_FLAG_NO_FULLSCREEN = 0x02000000
}
}
}
}