横屏时限制输入法全屏的方法

一是在源码里进行修改。

frameworks/base/core/java/android/inputmethodservice/InputMethodService.java

1、 在updateFullscreenMode(..)中,将boolean isFullscreen = mShowInputRequested && onEvaluateFullscreenMode();

改为boolean isFullscreen=false;

2、也可以:直接修改onEvaluateFullscreenMode()的返回值为false <自定义输入法时,可以直接重写之,就不必在源码中修改了>


二是在自己EditText的xml里加上属性

android:imeOptions="flagNoExtractUi"

防止EditTextView 或者AutoCompleteTextView默认获取焦点的方法

因为进入画面时是默认得到焦点的,要想不让其默认获得焦点,可以在控件前加一个o像素的layout,并设置他先得到焦点,也可以将其控件属性加入android:nextFocusUp="@+id/其它控件ID"无非就是想尽办法将这两个控件的焦点置于其他焦点之后

基本代码如下

        <LinearLayout            android:layout_width="0px"            android:layout_height="0px"            android:focusable="true"            android:focusableInTouchMode="true" >        </LinearLayout>        <AutoCompleteTextView            android:id="@+id/et_search"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginLeft="@dimen/map_common_10dp"            android:layout_weight="3"            android:background="@null"            android:hint="@string/map_page_location_edit_hint"            android:imeOptions="flagNoExtractUi"            android:maxLength="20"            android:paddingLeft="@dimen/map_common_10dp"            android:singleLine="true"            android:textColor="@color/map_common_color_767676"            android:textSize="@dimen/map_common_26px" />

这样就不会默认获取焦点了。


隐藏输入法键盘的方法


InputMethodManager inputMethodManager =(InputMethodManager)activity.getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); EditText editText = (EditText)findViewById(R.id.xxxx); inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0); //隐藏

更多相关文章

  1. 修改SeekBar样式
  2. android EditText自定义样式
  3. android根据字体大小设置控件高度
  4. 安卓开发09:常用控件-TextView文本展示
  5. ListView中item点击的时候颜色变化
  6. android界面开发小结——android笔记---控件和布局
  7. Android(安卓)开发中怎么使用自定义字体?
  8. Android学习笔记(九)
  9. android 设置时区

随机推荐

  1. 三步解决 Maven 无法下载依赖包的问题
  2. 前端 Docker 镜像体积优化
  3. 搭建 npm 私有镜像仓库
  4. 为 Centos7 配置 .htaccess 开启 URL 伪
  5. 盘点|2021年最受欢迎Linux桌面操作系统前
  6. 为 ECS Ubuntu 18.04 实例配置辅助私网 I
  7. MongoDB 4.2 内核解析 - Change Stream
  8. 插画人物如何构图?插画构图的正确方式
  9. thinkphp5 生成二维码
  10. JS返回上一页