Android软键盘遮挡控件
Android 大约 859 字解决方法
public void addLayoutListener(final View main, final View scroll) {
main.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect rect = new Rect();
main.getWindowVisibleDisplayFrame(rect);
int mainInvisibleHeight = main.getRootView().getHeight() - rect.bottom;
int screenHeight = main.getRootView().getHeight();//屏幕高度
if (mainInvisibleHeight > screenHeight / 4) {
int[] location = new int[2];
scroll.getLocationInWindow(location);
int srollHeight = (location[1] + scroll.getHeight()) - rect.bottom;
main.scrollTo(0, srollHeight);
} else {
main.scrollTo(0, 0);
}
}
});
}
阅读 479 · 发布于 2019-04-10
————        END        ————
扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
Java jar包启动时指定JVM时区阅读 1347
-
Spring Boot使用Session管理登录状态和拦截请求阅读 2007
-
走进Rust:结构体方法阅读 322
-
Spring Boot整合多数据源阅读 191
-
MySQL聚合函数阅读 435
-
算法每日一题20190620:整数反转阅读 486
-
Win10运行MonogDB时提示由于找不到VCRUNTIME140.dll(MSVCP140.dll)无法继续执行代码阅读 3224
-
PhpStorm设置大括号不换行阅读 2488
-
dubbo-admin Failed to invoke remote method: getMetricsByGroup阅读 2382
-
Linux -bash: locate: command not found阅读 62