当前位置:网站首页>Solve the problem that the input box is blocked by the pop-up keyboard under the WebView transparent status bar
Solve the problem that the input box is blocked by the pop-up keyboard under the WebView transparent status bar
2022-06-26 03:36:00 【kingsley1212】
Create a new class
public class WindowSoftModeAdjustResizeExecutor {
public static void assistActivity(Activity activity) {
new WindowSoftModeAdjustResizeExecutor(activity);
}
private View mChildOfContent;
private int usableHeightPrevious;
private FrameLayout.LayoutParams frameLayoutParams;
private WindowSoftModeAdjustResizeExecutor(Activity activity) {
FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);
mChildOfContent = content.getChildAt(0);
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
possiblyResizeChildOfContent();
}
});
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
}
private void possiblyResizeChildOfContent() {
int usableHeightNow = computeUsableHeight();
if (usableHeightNow != usableHeightPrevious) {
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
mChildOfContent.requestLayout();
usableHeightPrevious = usableHeightNow;
}
}
private int computeUsableHeight() {
Rect r = new Rect();
mChildOfContent.getWindowVisibleDisplayFrame(r);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return (r.bottom - r.top);
}
return r.bottom;
}
}
In use . Which one? Activity It's covered , Just call this code
/**
* Solve the problem under the transparent status bar , Pop up the problem that the keyboard blocks the input box
*/
WindowSoftModeAdjustResizeExecutor.assistActivity(this);
And it should be in the corresponding... Of the manifest file activity It says in it
android:windowSoftInputMode="adjustResize|stateHidden"
边栏推荐
- Leetcode 175 Combine two tables (2022.06.24)
- Click event
- todolist未完成,已完成
- 文献阅读---优化RNA-seq研究以研究除草剂耐药性(综述)
- Authorization of database
- 路由跳轉之點擊列錶的操作按鈕,跳轉至另一個菜單頁面並激活相應的菜單
- MySQL开发环境
- Utonmos: digital collections help the inheritance of Chinese culture and the development of digital technology
- 解决uniapp插件robin-editor设置字体颜色和背景颜色报错的问题
- Types and application methods of screen printing
猜你喜欢
![[hash table] a very simple zipper hash structure, so that the effect is too poor, there are too many conflicts, and the linked list is too long](/img/82/6a81e5b0d5117d780ce5910698585a.jpg)
[hash table] a very simple zipper hash structure, so that the effect is too poor, there are too many conflicts, and the linked list is too long

MySQL开发环境

Kotlin quick start

云计算基础-0

Qt 中 deleteLater 使用总结

Stm32cubemx: watchdog ------ independent watchdog and window watchdog

Mysql database foundation

Multimedia elements, audio, video
![[reading papers] fbnetv3: joint architecture recipe search using predictor training network structure and super parameters are all trained by training parameters](/img/84/2b66b513a0a36464233708fbb4b57d.png)
[reading papers] fbnetv3: joint architecture recipe search using predictor training network structure and super parameters are all trained by training parameters

todolist未完成,已完成
随机推荐
【论文笔记】Supersizing Self-supervision: Learning to Grasp from 50K Tries and 700 Robot Hours
360 秒了解 SmartX 超融合基础设施
【论文笔记】Deep Reinforcement Learning Control of Hand-Eye Coordination with a Software Retina
云计算基础-0
Upload file / text / picture, box shadow
Types and application methods of screen printing
Clion项目中运行多个main函数
【哈希表】改进,拉链法哈希结构——直接用两个索引查找,不用每次都hash和%一遍
Analysis on the diversification of maker space mechanism construction
【论文笔记】Learning to Grasp with Primitive Shaped Object Policies
项目部署遇到的问题-生产环境
数字孪生智慧水务,突破海绵城市发展困境
解析社交机器人中的技术变革
On virtual memory and oom in project development
开通基金账户是安全的吗?怎么申请呢
解析少儿编程的多元评价体系
给网站添加“开放搜索描述“以适配浏览器的“站点搜索“
Digital twin intelligent water service, breaking through the development dilemma of sponge City
进度条
在哪里开基金帐户安全?