都是来自网友收集,以前也搞过忘了,今天又遇到,测试环境Android api28
showInfo = (TextView) findViewById(R.id.textView_xinxi); showInfo.setFocusable(true);//解决默认焦点问题,把焦点移动到没有输入的控件上 showInfo.setFocusableInTouchMode(true);//顺序不能变 showInfo.requestFocus();//请求焦点 showInfo.findFocus();
这种方法比较好 可以完美实现。也可以用
getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);//关闭后无法显示输入法框,还要用
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);//允许输入法框弹出
其他的方法都试了比如:android:windowSoftInputMode="stateVisible|adjustPan"已经不好意,记得以前老版本可以
留个位置,自己以后来找。