当前位置:网站首页>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
边栏推荐
- 机器学习理论之(7):核函数 Kernels —— 一种帮助 SVM 实现非线性化决策边界的方式
- iptables初探
- Teach you to quickly rename folder names in a few simple steps
- How can programmers quickly develop high-quality code?
- Esp32 (UART ecoh) - serial port echo worm learning (2)
- Daily CISSP certification common mistakes (April 19, 2022)
- QT excel operation summary
- [popular science] CRC verification (I) what is CRC verification?
- Daily CISSP certification common mistakes (April 11, 2022)
- Daily network security certification test questions (April 15, 2022)
猜你喜欢
随机推荐
Sentinel service fusing practice (sentinel integration ribbon + openfeign + fallback)
Implementation of TCP UDP communication with golang language
深入理解 Golang 中的 new 和 make 是什么, 差异在哪?
ESP32 LVGL8. 1. Detailed migration tutorial of m5stack + lvgl + IDF (27)
About the operation of unit file reading (I)
Kettle paoding jieniu Chapter 17 text file output
Domestic GD chip can filter
CISSP certified daily knowledge points (April 14, 2022)
Loop path
Configure iptables
Daily network security certification test questions (April 12, 2022)
机器学习理论之(7):核函数 Kernels —— 一种帮助 SVM 实现非线性化决策边界的方式
WiFi ap6212 driver transplantation and debugging analysis technical notes
Custom prompt box MessageBox in QT
ESP32 LVGL8. 1 - calendar (calendar 25)
Ctfshow - web362 (ssti)
Iptables - L executes slowly
Daily CISSP certification common mistakes (April 12, 2022)
Nacos作为服务配置中心实战
ESP32 LVGL8. 1 - textarea text area (textarea 26)