当前位置:网站首页>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"
边栏推荐
- Business process diagram design
- 显卡、GPU、CPU、CUDA、显存、RTX/GTX及查看方式
- Is it safe to open a fund account? How to apply
- 经典模型——NiN&GoogLeNet
- 小程序或者for循序要不要加key?
- Insect structure and Deconstruction
- Analysis of the multiple evaluation system of children's programming
- Where is it safe to open a fund account?
- Gradient
- 多媒体元素,音频、视频
猜你喜欢
【哈希表】很简单的拉链法哈希结构,以至于效果太差,冲突太多,链表太长
Review of the paper: unmixing based soft color segmentation for image manipulation
Tupu software is the digital twin of offshore wind power, striving to be the first
Clion项目中运行多个main函数
解决uniapp插件robin-editor设置字体颜色和背景颜色报错的问题
Deletelater Usage Summary in QT
Analysis on the diversification of maker space mechanism construction
使用IDEA画结构图
【读点论文】FBNetV3: Joint Architecture-Recipe Search using Predictor Pretraining 网络结构和超参数全当训练参数给训练了
Hardware creation principle of campus maker space
随机推荐
Drag and drop
UE5全局光照系統Lumen解析與優化
类图
USB driver -debug
MySQL development environment
[QT] custom control - switch
Types and application methods of screen printing
Graphics card, GPU, CPU, CUDA, video memory, rtx/gtx and viewing mode
Interpreting Oracle
国信金太阳靠谱吗?开证券账户安全吗?
文献阅读---优化RNA-seq研究以研究除草剂耐药性(综述)
Double carbon bonus + great year of infrastructure construction 𞓜 deep ploughing into the field of green intelligent equipment for water conservancy and hydropower
USB驱动-debug
Gradient
培育项目式Steam教育理念下的儿童创造力
Where is it safe to open a fund account?
USB peripheral driver - Enumeration
Network PXE starts winpe and supports UEFI and legacy boot
Analysis of the multiple evaluation system of children's programming
图扑软件数字孪生海上风电 | 向海图强,奋楫争先