EasyKeyBoardView-master.rar

上传者: yushanfenghailin | 上传时间: 2021-05-19 16:00:16 | 文件大小: 26.41MB | 文件类型: RAR
3)自定义键盘 方案1: 1)键盘在scrollview外面,布局写死,默认隐藏。 1)点击输入框显示键盘。 1)用键盘高度减去edittext高度得到scrollview移动距离,进行scrollview内容移动。 方案2: 今天美工说不是这种效果: 如果不用scrollview,就还是原来的效果,那么就写死一个view在dialod里面作为键盘,默认隐藏,主要是怎么顶布局,移的距离计算还是上面那种做法。 总结:需要注意几个地方: 1)隐藏系统键盘但光标正常显示 EditText et = viewHolder.getView(R.id.id_et); /** * 禁止Edittext弹出软件盘,光标依然正常显示,并且能正常选取光标 */ public static void disableShowSoftInput(EditText editText) { Class cls = EditText.class; Method method; try { method = cls.getMethod("setShowSoftInputOnFocus", boolean.class); method.setAccessible(true); method.invoke(editText, false); } catch (Exception e) { e.printStackTrace(); } } 1)计算输入的edittext与键盘高度差,再对rootView进行scrollBy滚动(顶布局)。 rootView.postDelayed(new Runnable() { @Override public void run() { int[] etSize = new int[2]; et.getLocationOnScreen(etSize); int etH = etSize[1]; int[] kbSize = new int[2]; keyBoardView.getLocationOnScreen(kbSize); int kbH = kbSize[1]; moveH = etH - kbH + et.getMeasuredHeight(); Log.i(TAG, "--->>>moveH:" + moveH); if (moveH > 0) { rootView.scrollBy(0, moveH); } } }, 100); 1)edittext选中和清楚选中。 private void selectAll(EditText currentEt) { et = currentEt; et.setSelectAllOnFocus(true); } private void clearSelectAll() { if(et != null){ //取消全选,主要是clearFocus起作用 et.setSelectAllOnFocus(false); et.clearFocus(); } } 1)要顶开的id_kb_root布局高度要设置成match_parent才行。 因为rootView.scrollBy其实是滚动的rootView的内部的孩子,如果是写死比如600dp,那么孩子滚动的时候其实是再rootView的600dp里面滚动的,就不会顶出到屏幕外面去。 1)自动将edittext中内容全选并获取焦点: et.setSelectAllOnFocus(true);//获得焦点时全选文本 et.requestFocus(); //请求获取焦点

文件下载

资源详情

[{"title":"( 2861 个子文件 26.41MB ) EasyKeyBoardView-master.rar","children":[{"title":".gitignore <span style='color:#111;'> 1001B </span>","children":null,"spread":false},{"title":".gitignore <span style='color:#111;'> 760B </span>","children":null,"spread":false},{"title":"build.gradle <span style='color:#111;'> 905B </span>","children":null,"spread":false},{"title":"AndroidManifest.xml <span style='color:#111;'> 1.33KB </span>","children":null,"spread":false},{"title":"ic_launcher.png <span style='color:#111;'> 4.73KB </span>","children":null,"spread":false},{"title":"......","children":null,"spread":false},{"title":"<span style='color:steelblue;'>文件过多,未全部展示</span>","children":null,"spread":false}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明