当前位置:网站首页>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"
边栏推荐
- USB driver -debug
- 上传文件/文本/图片,盒子阴影
- Deletelater Usage Summary in QT
- Business process diagram design
- Is it safe to open an account in flush online? How to open a brokerage account online
- Oracle connectivity issues and Solutions
- MySQL addition, deletion, query and modification (primary level)
- HL7Exception: Can‘t XML-encode a GenericMessage. Message must have a recognized struct
- 计组笔记 数据表示与运算 校验码部分
- MySQL development environment
猜你喜欢

论文回顾:Unmixing-Based Soft Color Segmentation for Image Manipulation

MySQL development environment

Click event

Oracle connectivity issues and Solutions

少儿编程对国内传统学科的推进作用

经典模型——NiN&GoogLeNet

Utonmos adheres to the principle of "collection and copyright" to help the high-quality development of traditional culture

类图

项目部署遇到的问题-生产环境

Components and routing
随机推荐
Classic model alexnet
Classic model – RESNET
redux-thunk 简单案例,优缺点和思考
Drag and drop
Click event
Butterknife unbinder uses flashback in fragment and viewpager
小程序或者for循序要不要加key?
UE5全局光照系統Lumen解析與優化
Cliquez sur le bouton action de la liste pour passer à une autre page de menu et activer le menu correspondant
国信金太阳靠谱吗?开证券账户安全吗?
jupyter notebook的插件安装以及快捷键
Components and routing
Redux thunk simple case, advantages, disadvantages and thinking
Gradient
Kotlin quick start
在哪里开基金帐户安全?
Qt编译出错ERROR: Unknown module(s) in QT: script
Matlab| short term load forecasting of power system based on BP neural network
Qt 中 deleteLater 使用总结
kitti2bag 安装出现的各种错误