【android监听软键盘事件并获取键盘高度】弱龄寄事外,委怀在琴书。这篇文章主要讲述android监听软键盘事件并获取键盘高度相关的知识,希望能为你提供帮助。
@Override public void onResume(){ super.onResume(); //获取当前屏幕内容的高度 getWindow().getDecorView().addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { //获取View可见区域的bottom Rect rect = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); //避免重复事件 String keyboardStatus = String.format("%d%d%d",bottom,oldBottom,rect.bottom); if(keyboardStatus.equals(lastKeyboardStatus)){ return; } lastKeyboardStatus = keyboardStatus; if(bottom!=0 & & oldBottom!=0 & & bottom - rect.bottom < = 0){ HashMap< String,Object> data = https://www.songbingjia.com/android/new HashMap< String, Object> (); data.put("eventName","hide"); ImUtils.dispatch("keyBoardEvent",data); }else { HashMap< String,Object> data = https://www.songbingjia.com/android/new HashMap< String, Object> (); data.put("eventName","show"); data.put("height",bottom - rect.bottom); ImUtils.dispatch("keyBoardEvent",data); } } }); }
推荐阅读
- 解决错误:Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.(示例
- [Hyperapp] Interact with the State Object through Hyperapp Action functions
- 利用命令行删除Android系统自带应用的方法
- Android音视频深入十二FFmpeg视频替换声音(附源码下载)
- Android音视频深入十一FFmpeg和AudioTrack播放声音(附源码下载)
- monkey-获取app包名
- 如何让A20,android开机自动启动C程序
- RULES OF SURVIVAL 1.115153.115248 Full Apk + Data for Android
- 利用微信公众号快速推广APP应用