当前位置:网站首页>Click the input box to pop up the keyboard layout and move up
Click the input box to pop up the keyboard layout and move up
2022-04-23 18:42:00 【Xiao Xiaofeng】
- Keyboard pop-up monitoring ,
lineTaskbottom = (AutoLinearLayout) findViewById(R.id.line_taskbottom);
lineparams = new LinearLayout.LayoutParams(AutoLinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
editAdded.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
// When the keyboard pops up and hides, it will Call this method .
@Override
public void onGlobalLayout() {
Rect r = new Rect();
// Get the visual part of the current interface
this.getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
// Get the height of the screen
int screenHeight = this.getWindow().getDecorView().getRootView().getHeight();
// Here is used to get the height of the keyboard , When the keyboard doesn't pop up This height is 0 When the keyboard pops up, it is a positive number
int heightDifference = screenHeight - r.bottom;
Log.d("Keyboard Size", "Size: " + heightDifference);
if (heightDifference > 0) {
lineparams.setMargins(0, heightDifference-120, 0, 0);
lineTaskbottom.setLayoutParams(lineparams);
} else {
lineparams.setMargins(0, 10, 0, 0);
lineTaskbottom.setLayoutParams(lineparams);
}
}
});
版权声明
本文为[Xiao Xiaofeng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210604091467.html
边栏推荐
- Teach you to quickly rename folder names in a few simple steps
- Seata处理分布式事务
- Use bitnami / PostgreSQL repmgr image to quickly set up PostgreSQL ha
- Nacos作为服务配置中心实战
- 纠结
- STM32: LCD display
- Introduction to QT programming
- Introduction to ROS learning notes (II)
- Practice of Druid SQL and security in meituan review
- In shell programming, the shell file with relative path is referenced
猜你喜欢
Tangle
ESP32 LVGL8. 1 - input devices (input devices 18)
The first leg of the national tour of shengteng AI developer creation and enjoyment day was successfully held in Xi'an
【科普】CRC校验(一)什么是CRC校验?
Druid SQL和Security在美团点评的实践
How to restore MySQL database after win10 system is reinstalled (mysql-8.0.26-winx64. Zip)
7、 DOM (Part 2) - chapter after class exercises and answers
视频边框背景如何虚化,简单操作几步实现
[mathematical modeling] - analytic hierarchy process (AHP)
iptables -L执行缓慢
随机推荐
Seata handles distributed transactions
Chondroitin sulfate in vitreous
WiFi ap6212 driver transplantation and debugging analysis technical notes
根据快递单号查询物流查询更新量
Use bitnami / PostgreSQL repmgr image to quickly set up PostgreSQL ha
Introduction to quantexa CDI syneo platform
Cutting permission of logrotate file
ESP32 LVGL8. 1 - slider slider (slider 22)
[popular science] CRC verification (I) what is CRC verification?
Machine learning theory (7): kernel function kernels -- a way to help SVM realize nonlinear decision boundary
Const keyword, variable and function are decorated with const
Stm32mp157 wm8960 audio driver debugging notes
Sentinel规则持久化进Nacos
The first leg of the national tour of shengteng AI developer creation and enjoyment day was successfully held in Xi'an
昇腾 AI 开发者创享日全国巡回首站在西安成功举行
K210 serial communication
MVVM模型
22 year flying Book manpower Kit
listener. log
Esp32 (UART receiving and sending) - receiving and sending communication of serial port (4)