Android输入法遮挡了输入框,使用android:fitsSystemWindows=true后界面顶部出现白条
问题:
1、页面布局文件:
<com.zhy.autolayout.AutoLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/layout_order_detail"android:layout_width="match_parent"android:layout_height="match_parent" android:fitsSystemWindows="true"android:orientation="vertical">
2、配置文件不设置android:windowSoftInputMode属性;
效果图:
3、加入android:fitsSystemWindows="true"后,解决了输入法遮挡了输入框的问题,但是界面顶部出现了状态栏高度的白条。
解决方法:
1、自定义CustomLinearLayout(因为我页面最外层是LinearLayout)继承LinearLayout,重写fitSystemWindows和onApplyWindowInsets两个方法:
public class CustomLinearLayout extends AutoLinearLayout {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);}public CustomLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {super(context, attrs, defStyleAttr, defStyleRes);}@Overrideprotected 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)@Overridepublic 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;}}
}
2、修改布局文件:
<com.example.widget.CustomLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/layout_order_detail"android:layout_width="match_parent"android:layout_height="match_parent"android:fitsSystemWindows="true"android:orientation="vertical">
3、配置文件不设置android:windowSoftInputMode属性;
4、效果图:
问题解决。
Android输入法遮挡了输入框,使用android:fitsSystemWindows=true后界面顶部出现白条相关推荐
- Android输入法遮挡了输入框,使用android:fitsSystemWindows=“true“后界面顶部出现白条解决方案
Android输入法遮挡了输入框,使用android:fitsSystemWindows="true"后界面顶部出现白条解决方案 参考文章: (1)Android输入法遮挡了输入框 ...
- 2022-09-06 Android输入法顶起输入框,遮挡RecyclerView
背景 IM项目中的会话界面,一般就是顶部一个标题,底部是输入区域,中间显示消息列表. 微信的会话界面中,进入会话界面,有以下几点: 隐藏输入法 当消息数量能占满屏幕时,底部显示最后一条,依次往上排列 ...
- 解决 android 输入法弹出输入框被遮挡的问题
解决 android 输入法弹出输入框被遮挡的问题 由于本人懒,也从不写博客,之所以写是因为这次开发 '又遇到' 输入法这个问题了,好久以前有遇到过,突然发现还是很有必要把他分享出来,言归正传,下面就 ...
- android输入法中文在哪里设置,android输入法怎么设置中文
android输入法怎么设置中文?对于Android开发者来说,好的模拟器可以事半功倍,特别是在现在Android设备层出不穷的市场中,为了兼容各个版本,需要模拟器和真机的测试,真机成本不小,模拟器是 ...
- android输入法把底部顶起来,Android 输入法将底部布局顶上去遮挡布局问题
最近在项目中遇到使用ReletiveLayout将View固定在底部,但弹出输入框时底部的View被顶上去的问题, 尝试了很多解决办法 ,如下: 方法一:在你的activity中的oncreate中s ...
- 处理VUE移动端输入法遮挡input输入框的问题
1.tmplate <input v-model="id" @blur="blurIn"> 2.methods blurIn() {window.s ...
- Android11键盘弹出动画,(2016-11-04完美解决)移动端iOS第三方输入法遮挡底部input及android键盘回落后留白问题...
问题概述 问题1:H5 web 移动端 输入框, 键盘唤起后fixed定位好的元素跟随页面滚动了起来- fixed属性失效了!满屏任性横飞, 如下图: 问题2:有几后来含些在到气时按式近篇来又的方浏消 ...
- android 输入法遮挡布局解决方案
android 记一次解决键盘遮挡问题 https://www.cnblogs.com/taixiang/p/10091883.html
- 输入法遮挡EditText输入框的问题
一:在清单文件中对应的Activity便签下添加如下配置 android:windowSoftInputMode="stateVisible|adjustResize" 二:在对应 ...
最新文章
- vue-cli3.0 移动端适配
- 项目经理的几个重要转变
- ym——Android之ListView性能优化
- Struts2.x中获取request,response,session的方式
- oracle去掉默认值sql,如何在T-SQL中删除默认值或类似约束?
- linux远程桌面MacOS,如何在Linux或macOS中使用远程桌面连接到Windows 10 | MOS86
- javascript 遍历数组的常用方法(迭代、for循环 、for… in、for…of、foreach、map、filter、every、some,findindex)
- Linux 如何配置 SFTP 来代替单一ftp应用
- DS4000系列存储配置storage manager介绍
- 智能优化算法学习总结
- PC版微信扫描登陆原理
- 大话设计模式笔记(二十四)の解释器模式
- linux 网桥端口,linux网桥
- 恒虚警率(Constant False Alarm Rate)检测
- Easy Connect连接网络请求异常
- 统计学 计算机论文发表,数学科学学院博士生史册在统计学顶级期刊
《Annals of Statistics》上发表论文...
- 如何启用/开启本机的IIS服务
- 【网络安全】——服务端安全(注入攻击、认证与会话管理和访问控制、访问控制、加密算法与随机数、Web框架安全、应用层拒绝服务攻击DDOS)
- SQL语句:分组查询
- 解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com