安卓加载h5 ,h5界面有输入框 ,安卓键盘会被遮住 。

我是在全屏的状态下 这样设置有效(亲测)

class CustomLinearLayout: LinearLayout {    constructor(context: Context?): super(context) {    }   constructor(context: Context?, attrs: AttributeSet?):  super(context, attrs) {    }   constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int): super(context, attrs, defStyleAttr) {    }    override fun fitSystemWindows(insets: Rect): Boolean {        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {            insets.left = 0            insets.top = 0            insets.right = 0        }        return super.fitSystemWindows(insets)    }    @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)    override fun onApplyWindowInsets(insets: WindowInsets): WindowInsets? {        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {            super.onApplyWindowInsets(                insets.replaceSystemWindowInsets(                    0,                    0,                    0,                    insets.systemWindowInsetBottom                )            )        } else {            insets        }    }}

 

此处是ktlion代码

 

public class CustomLinearLayout extends LinearLayout {    public CustomLinearLayout(Context context) {        super(context);    }    public CustomLinearLayout(Context context, AttributeSet attrs) {        super(context, attrs);    }    public CustomLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {        super(context, attrs, defStyleAttr);    }      @Override    protected boolean fitSystemWindows(Rect insets) {        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {            insets.left = 0;            insets.top = 0;            insets.right = 0;        }        return super.fitSystemWindows(insets);    }    @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)    @Override    public WindowInsets onApplyWindowInsets(WindowInsets insets) {        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {            return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0, insets.getSystemWindowInsetBottom()));        } else {            return insets;        }    }}

此处是java代码 我都贴出来 害怕有些人看不懂kotlin 

更改布局的第一个节点 替换为自定义的类

AndroidManifest不用设置什么

希望能帮到各位

更多相关文章

  1. Android串口开发,基于官方的android-serialport-api增加支持设置
  2. Android(安卓)Window PhoneWindow DecorView
  3. Android成长(二)——两个页面交互
  4. android手机打电话代码分析
  5. Android(安卓)WIndow,WindowManager简单介绍
  6. android:EditText属性/去边框
  7. Android(安卓)Platform 3.0 SDK和Eclipse ADT安装记录三
  8. android UI进阶之弹窗的使用(2)--实现通讯录的弹窗效果
  9. Android开发之dagger.android--Activity

随机推荐

  1. Android7.0 系统启动流程---system_serve
  2. 如何使用android sdk开发应用
  3. 如何使Android应用程序获取系统权限来修
  4. android Canvas用法
  5. android传输视频到PC
  6. Android中的网络时间同步
  7. Android系统服务 WMS与AMS简单理解
  8. android window窗口机制
  9. Android应用程序防止被LMK干掉
  10. mysql 5.7.16 免安装版安装配置方法图文