参考:

  https://developer.android.com/training/keyboard-input/visibility.html

1,进入Activity时,EditText就获得焦点并显示输入软键盘。

  如果EditText所在的activity是Activity是主activity,那么以上行为是默认的,不是的话,要设置Activity的属性:

 <application ... >
<activity
android:windowSoftInputMode="stateVisible" ... >
...
</activity>
...
</application>

  注意,如果键盘是按键的,那么不显示键盘,只显示光标。

2,使用代码控制显示软键盘和焦点。

  调用下面的方法就可让某个view可输入文本:

 public void showSoftKeyboard(View view) {//指定想要输入键盘的view
if (view.requestFocus()) {//1,取得焦点
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);//2,用InputMethodManager显示键盘
}
}

  关闭键盘不用代码,按回车或返回键后自动消失。

3,控制键盘与页面控件的布局方式,可让键盘不挡住页面上的控件并可以滚动等。如:

     <activity android:name=".MainActivity"
android:windowSoftInputMode="stateVisible|adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

4,详细的软键盘显示参数

<activity android:windowSoftInputMode="stateVisible|adjustResize" . . . >

  Values set here (other than "stateUnspecified" and "adjustUnspecified") override values set in the theme.

Value Description
"stateUnspecified"

The state of the soft keyboard (whether it is hidden or visible) is not specified.

The system will choose an appropriate state or rely on the setting in the theme.

This is the default setting for the behavior of the soft keyboard.

默认的显示方式,不指定参数。

"stateUnchanged"

The soft keyboard is kept in whatever state it was last in, whether visible or hidden, when the activity comes to the fore.

按上次样式显示

"stateHidden"

The soft keyboard is hidden when the user chooses the activity — that is, when the user affirmatively navigates

forward to the activity, rather than backs into it because of leaving another activity.

当进入到activity且eidt有焦点时,不显示键盘。

"stateAlwaysHidden"

The soft keyboard is always hidden when the activity's main window has input focus.

总是不显示软键盘。

"stateVisible"

The soft keyboard is visible when that's normally appropriate (when the user is navigating forward to the activity's main window).

显示软键盘

"stateAlwaysVisible"

The soft keyboard is made visible when the user chooses the activity — that is, when the user affirmatively navigates forward to

the activity, rather than backs into it because of leaving another activity.

当进入或离开时activity时,一直显示软键盘。

"adjustUnspecified"

It is unspecified whether the activity's main window resizes to make room for the soft keyboard, or whether the contents of the

window pan to make the current focus visible on-screen. The system will automatically select one of these modes depending on

whether the content of the window has any layout views that can scroll their contents. If there is such a view, the window will be

resized, on the assumption that scrolling can make all of the window's contents visible within a smaller area.

This is the default setting for the behavior of the main window.

"adjustResize"

The activity's main window is always resized to make room for the soft keyboard on screen.

Activity的主窗口会缩放,以让软键盘不挡住view。

"adjustPan"

The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically

panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally

less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

  This attribute was introduced in API Level 3.

EditText(5)如何控制输入键盘的显示方式及参数表的更多相关文章

  1. GridLayout自定义数字键盘(两个EditText)

    功能说明: 适用于两个EditText输入框,并控制输入字符的长度,点击键盘中的"确定"按钮完成输入,点击"前一项"光标跳到前一个EditText 运行效果图如 ...

  2. Android Edittext 显示光标 获取焦点 监听焦点

    Edittext java 代码控制获取焦点 EditText mEditText = (EditText) findViewById(R.id.et); mEditText.setFocusable ...

  3. CSS基础选择器(选择器的优先级),CSS样式块( 长度/颜色/显示方式/文本样式),盒模型组成,盒模型-block,盒模型布局

    CSS基础选择器 (1)id选择器:   #       =>  标签拥有 id="user"  属性 <style> #user { width: 200px; ...

  4. android基本控件学习-----EditText

    EditText的讲解 一.<实例一>:用户登录 <?xml version="1.0" encoding="utf-8"?> < ...

  5. 自定义Visual Studio调试器中的对象显示方式

    你有没有盯着调试器窗口中的对象,并希望你可以通过其他类型的东西来查看这些对象?我当然有!扩展项目以确定每个人的身份可能会非常快速.理想情况下,通过特定的属性值快速定位它们会很棒.对我们来说幸运的是,V ...

  6. 进程控制之exec函数

    用fork函数创建子进程后,子进程往往要调用一种exec函数以执行另一个程序.当进程调用一种exec函数时,该进程执行的程序完全替换为新程序,而新程序则从其main函数开始执行.因为调用exec并不创 ...

  7. 大白话 Scala 控制抽象

    2019-04-14 关键字: Scala.Scala控制抽象.Scala高阶函数 本篇文章系笔者根据当前掌握的知识对 Scala 控制抽象的教材知识总结,不保证文章所述内容的绝对.完全正确性. 在 ...

  8. Linux网络编程学习(三) ----- 进程控制实例(第三章)

    本节主要介绍一个进程控制的实例,功能就是在前台或者后台接收命令并执行命令,还能处理由若干个命令组成的命令行,该程序命名为samllsh. 基本逻辑就是 while(EOF not typed) { 从 ...

  9. 基于FPGA的5寸LCD显示屏的显示控制

    基于FPGA的5寸LCD显示屏的显示控制 作者:lee神 1,图像处理基础知识 数字图像处理是指将图像信号转换成数字信号并利用计算机对其进行处理的过程.图像处理最早出现于 20 世纪 50 年代,当时 ...

随机推荐

  1. Java高概率面试题目—finally

    在Java面试中关于finally的面试题目出现的概率非常高,而且一旦面试官问起绝不会是蜻蜓点水,而是会向你发起层层递进地“连环问”,并且回答这系列问题常常需要代码的辅助,可谓考验基础的面试利题.究竟 ...

  2. [bzoj3527][Zjoi2014]力_FFT

    力 bzoj-3527 Zjoi-2014 题目大意:给定长度为$n$的$q$序列,定义$F_i=\sum\limits_{i<j}\frac{q_iq_j}{(i-j)^2}-\sum\lim ...

  3. 基于图片识别服务的IOS图片识别程序

    由于TensorFlow提供的IOS版Demo相对于Android版识别率不高,所以开发了通过识别服务进行图片识别的IOS版程序. 该程序基于图片识别服务(http://www.cnblogs.com ...

  4. restful接口就是url嘛,通过http请求发起访问。那接口进行监控,就可以监控这个restful url嘛

    EasyAPI接口管理系统 专注API接口监控,让您的API接口更稳定,与APP更紧密 + 购买监控服务 接口性能分析 分析App对应的API接口请求性能,包含HTTP响应时间.吞吐率.HTTP错误率 ...

  5. 我的arcgis培训照片12

    来自:http://www.cioiot.com/successview-381-1.html

  6. 使用OpenCV读、操作、写图像并与bash合作对某个文件夹下全部图像进行相似处理

    我门要对某个文件夹下全部图像文件进行统一处理,假设图像的数量过多.那么手动地一张张处理就会显得有些麻烦.本文使用OpenCV和bash来完毕我们指定的任务. 任务 将文件夹A下的全部统一格式的jpg图 ...

  7. yarn-cli 缓存

    yarn cache list Yarn 会在你的用户目录下开辟一块全局缓存用以保存下载的包.yarn cache list 用于列出所有已经缓存的包. yarn cache dir 执行 yarn ...

  8. Eclipse 常用快捷键及使用技巧

    做 java 开发的,经常会用 Eclipse 或者 MyEclise 集成开发环境,一些实用的 Eclipse 快捷键和使用技巧,可以在平常开发中节约出很多时间提高工作效率,下面我就结合自己开发中的 ...

  9. CCBPM工作流引擎的消息机制与设计

    keyword:ccflowjflow 消息机制流程引擎 自己主动发送短信 发送邮件 发送消息 流程引擎微信连接 消息接口 关于ccbpm: 我们把ccflow jflow两个版本号的工作流引擎统称为 ...

  10. HDU5768Lucky7

    Lucky7 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...