首页 > 解决方案 > 当 windowSoftInputMode=“adjustResize” 带有半透明动作/导航栏时,显示和隐藏键盘需要时间

问题描述

windowSoftInputMode=“adjustResize”不使用半透明动作/导航栏所以我创建了自定义布局

public class CustomRelativeLayout:RelativeLayout
{
    private int[] mInsets = new int[4];

    public CustomRelativeLayout(Context context) : base(context)
    {
    }

    public CustomRelativeLayout(Context context, IAttributeSet attrs) : base(context, attrs)
    {
    }

    public CustomRelativeLayout(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
    {
    }


    public override WindowInsets OnApplyWindowInsets(WindowInsets insets)
    {
        if (Build.VERSION.SdkInt >= Build.VERSION_CODES.KitkatWatch)
        {
            //insets.ReplaceSystemWindowInsets(0, 0, 0, insets.SystemWindowInsetBottom);
            return base.OnApplyWindowInsets(insets.ReplaceSystemWindowInsets(0,0,0, insets.SystemWindowInsetBottom));
        }
        else
        {
            return insets;
        }
    }


}

但是显示和隐藏键盘需要时间,甚至需要时间来推动布局。怎么解决???

标签: androidxamarin.android

解决方案


添加以下属性

android:fitsSystemWindows="true"

在片段 .xml 布局的根 RelativeLayout 中。

这是一个类似的问题,您可以参考。


推荐阅读