界面底部的edittext被弹出的软键盘覆盖的问题解决方法
来源:互联网 发布:华为手机全球销量知乎 编辑:程序博客网 时间:2024/04/29 21:53
1:如果布局文件不存在toolbar,则直接在布局文件中根布局外面添加<Scrollview/>;
如果布局文件中存在<include/>导入的toolbar,则可将toobar下面的所有布局包裹在<Scrollview/>中;
2:在根布局中设置参数android:fitsSystemWindows="true" ;注:如果有设置windowSoftInputMode="adjustPan",要取消,否则会冲突;
3:如果出现状态栏变透明,则在项目内重写一个CustomLayout类继承你的根布局LinearLayout或RelativeLayout等,后将你的布局文件内根布局改为CustomLayout,注意,此时需要标注清楚类路径,如com.***.***.CustomLayout。重写类的方法如下:
import android.content.Context;
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.view.WindowInsets;
import android.widget.RelativeLayout;
public class SoftInputRelativeLayout extends RelativeLayout {
private int[] mInsets = new int[4];
public SoftInputRelativeLayout(Context context) {
super(context);
}
public SoftInputRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public WindowInsets computeSystemWindowInsets(WindowInsets in, Rect outLocalInsets) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// Intentionally do not modify the bottom inset. For some reason,
// if the bottom inset is modified, window resizing stops working.
// TODO: Figure out why.
mInsets[0] = outLocalInsets.left;
mInsets[1] = outLocalInsets.top;
mInsets[2] = outLocalInsets.right;
outLocalInsets.left = 0;
outLocalInsets.top = 0;
outLocalInsets.right = 0;
}
return super.computeSystemWindowInsets(in, outLocalInsets);
}
@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
mInsets[0] = insets.getSystemWindowInsetLeft();
mInsets[1] = insets.getSystemWindowInsetTop();
mInsets[2] = insets.getSystemWindowInsetRight();
return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0,
insets.getSystemWindowInsetBottom()));
} else {
return insets;
}
}
}
上述方法中,可针对你的根布局,将RelativeLayout修改成相应的需要继承的布局文件即可。
注:文章参考链接:https://segmentfault.com/q/1010000004579431
https://stackoverflow.com/questions/21092888/windowsoftinputmode-adjustresize-not-working-with-translucent-action-navbar
- 界面底部的edittext被弹出的软键盘覆盖的问题解决方法
- 解决 侵入式下 EditText位于屏幕底部时会被软键盘覆盖的问题
- Android的EditText不弹出软键盘的方法
- EditText只显示光标不弹出软键盘的方法
- 避免 EditText 弹出软键盘的处理方法
- [Android] EditText默认不弹出软键盘的方法
- android EditText不弹出软键盘的方法
- 定位底部的输入框被软键盘覆盖解决方案
- EditText软键盘的弹出与关闭
- 解决EditText被软键盘覆盖的问题
- Android软键盘的弹出 隐藏部分界面的方法
- EditText软键盘弹出问题解决
- Android虚拟软键盘弹出时的界面控制方法
- 当EditText被点击的时候不弹出软键盘
- android弹出软键盘时,editText被遮挡的问题
- 在含有EditText的界面中,如何避免软键盘的弹出
- 包含EditText组件的界面中,禁止自动弹出软键盘
- Android - 弹出的软键盘,不会覆盖整个界面了哦
- 微信小程序——unionId
- IaaS,PaaS,SaaS 的区别
- pydev在Elipse中使用第三方组件时,显示“Undefined variable from import:xxx()"的解决方案
- CCF 无线网络
- Spring整合JUnit4之java.lang.ExceptionInInitializerError
- 界面底部的edittext被弹出的软键盘覆盖的问题解决方法
- nyoj 1248 海岛争霸
- 安卓_解析
- java 创建验证码,图片,可直接运行
- python 遍历文件夹
- 事务并发处理带来的问题
- 关于asyncio的ValueError: too many file descriptors in select()错误
- 网站的安全架构
- 一种排序