当前位置:网站首页>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
边栏推荐
- 程序员如何快速开发高质量的代码?
- Tangle
- 昇腾 AI 开发者创享日全国巡回首站在西安成功举行
- 机器学习理论之(8):模型集成 Ensemble Learning
- ESP32 LVGL8. 1 - input devices (input devices 18)
- [popular science] CRC verification (I) what is CRC verification?
- ctfshow-web361(SSTI)
- Machine learning theory (8): model integration ensemble learning
- Daily network security certification test questions (April 18, 2022)
- 22年字节跳动飞书人力套件三面面经
猜你喜欢
随机推荐
Esp32 (UART ecoh) - serial port echo worm learning (2)
Ctfshow - web362 (ssti)
On iptables
Function recursion and solving interesting problems
os_authent_prefix
Custom prompt box MessageBox in QT
Database computer experiment 4 (data integrity and stored procedure)
iptables初探
迁移学习进阶
Setting up keil environment of GD single chip microcomputer
Ionic instruction set order from creation to packaging
listener.log
PyGame tank battle
Daily CISSP certification common mistakes (April 14, 2022)
Can filter
Domestic GD chip can filter
ctfshow-web362(SSTI)
Daily CISSP certification common mistakes (April 13, 2022)
Sentinel服务熔断实战(sentinel整合ribbon+openFeign+fallback)
C language simulates entering and leaving the stack, first in first out, first in first out, shared memory








