Android 使用Xamarin表单更新到AppCompat后WebView中的白色覆盖

Android 使用Xamarin表单更新到AppCompat后WebView中的白色覆盖,android,webview,xamarin,xamarin-forms,Android,Webview,Xamarin,Xamarin Forms,在我的Xamarin表单应用程序中,我通过插入一个div将contentEditable设置为true,将一个WebView用作表单。在更新到AppCompatstyles之前,一切正常 现在,当用户试图在网络视图中写入内容时,会出现一个奇怪的白色覆盖层(白色正方形),当键盘关闭时,该覆盖层消失。为了找到问题的根本原因,我创建了一个示例项目,其中只有一个页面包含一个垂直堆栈布局,其中包含另一个堆栈布局和webview。我注意到,如果内部堆栈布局的高度足以使webview在出现时被键盘覆盖,则会出

在我的
Xamarin表单
应用程序中,我通过插入一个div将
contentEditable
设置为true,将一个
WebView
用作表单。在更新到
AppCompat
styles之前,一切正常

现在,当用户试图在
网络视图
中写入内容时,会出现一个奇怪的白色覆盖层(白色正方形),当键盘关闭时,该覆盖层消失。为了找到问题的根本原因,我创建了一个示例项目,其中只有一个页面包含一个垂直堆栈布局,其中包含另一个堆栈布局和webview。我注意到,如果内部堆栈布局的高度足以使webview在出现时被键盘覆盖,则会出现此问题。在这种情况下,webview被向上推,出现这种奇怪的覆盖。webview功能齐全,可以编写文本,即使文本被这个白色方块隐藏,但当键盘关闭时,文本就会消失

这是一个可用于测试问题的简单页面示例。添加按钮只是为了增加和减少布局的大小,以便更容易地显示问题

public class MainPage : ContentPage
{
    const string ContentEdit = @"<div contentEditable=""true"" style =""min-height: 200px"">";
    const string ContentEditEnd = "</div>";
    const string EmptyDocument = @"<body>" + ContentEdit + ContentEditEnd + @"</body>";

    WebView webView;

    public MainPage()
    {
        InitializePage();
    }

    void InitializePage()
    {
        webView = new WebView()
        {
            VerticalOptions = LayoutOptions.FillAndExpand,
            HorizontalOptions = LayoutOptions.FillAndExpand,
        };

        var button1 = new Button
        {
            HorizontalOptions = LayoutOptions.CenterAndExpand,
            VerticalOptions = LayoutOptions.CenterAndExpand,
            Text = "-",
        };

        var button2 = new Button
        {
            HorizontalOptions = LayoutOptions.CenterAndExpand,
            VerticalOptions = LayoutOptions.CenterAndExpand,
            Text = "+",
        };

        var tallLayout = new StackLayout()
        {
            Orientation = StackOrientation.Horizontal,
            HeightRequest = 200, 
            BackgroundColor = Color.Lime,
            Children = { button1, button2, },
        };

        button1.Clicked += (sender, e) => tallLayout.HeightRequest = tallLayout.Height - 20;
        button2.Clicked += (sender, e) => tallLayout.HeightRequest = tallLayout.Height + 20;

        var layout = new StackLayout
        {
            Orientation = StackOrientation.Vertical,
            VerticalOptions = LayoutOptions.FillAndExpand,
            HorizontalOptions = LayoutOptions.FillAndExpand,
            Children = { tallLayout, webView },
        };

        Content = layout;
    }

    protected override void OnAppearing()
    {
        InitializeEmptyContent();
    }

    public void InitializeEmptyContent()
    {
        var htmlSource = new HtmlWebViewSource();
        htmlSource.Html = EmptyDocument;

        webView.Source = htmlSource;
    }
}
public类主页:ContentPage
{
常量字符串ContentEdit=@”;
常量字符串ContentEditEnd=“”;
常量字符串EmptyDocument=@“+ContentEdit+ContentEditEnd+@”;
网络视图;
公共主页()
{
初始化页面();
}
无效初始化页()
{
webView=新的webView()
{
VerticalOptions=LayoutOptions.FillAndExpand,
HorizontalOptions=LayoutOptions.FillAndExpand,
};
var button1=新按钮
{
水平选项=LayoutOptions.CenterAndExpand,
垂直选项=LayoutOptions.CenterAndExpand,
Text=“-”,
};
var button2=新按钮
{
水平选项=LayoutOptions.CenterAndExpand,
垂直选项=LayoutOptions.CenterAndExpand,
Text=“+”,
};
var tallLayout=new StackLayout()
{
方向=堆叠方向。水平,
高度请求=200,
BackgroundColor=颜色。石灰,
Children={button1,button2,},
};
按钮1.点击+=(发送者,e)=>tallLayout.HeightRequest=tallLayout.Height-20;
按钮2.点击+=(发送者,e)=>tallLayout.HeightRequest=tallLayout.Height+20;
var布局=新的StackLayout
{
方向=堆叠方向。垂直,
VerticalOptions=LayoutOptions.FillAndExpand,
HorizontalOptions=LayoutOptions.FillAndExpand,
Children={tallLayout,webView},
};
内容=布局;
}
出现时受保护的覆盖无效()
{
初始化EmptyContent();
}
public void InitializeEmptyContent()
{
var htmlSource=新的HtmlWebViewSource();
Html=EmptyDocument;
webView.Source=htmlSource;
}
}

我也曾尝试使用原生Android复制这个简单的布局,但似乎我没有任何类似的bug。这是Xamarin表单错误还是我做错了什么?

最后,问题被认为是Xamarin的问题