我的Android进阶之旅------>Android中android:windowSoftInputMode的使用方法
面试题:怎样在显示某个Activity时马上弹出软键盘?
答案:在AndroidManifest.xml文件里设置<activity>标签的android:windowSoftInputMode属性能够在显示Activity时马上弹出当前输入法的软键盘(无论是否有获得焦点的空间)。
设置为:android:windowSoftInputMode="stateVisible|adjustPan" 代码例如以下:
<activity
android:name=".RingstonActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:windowSoftInputMode="stateVisible|adjustPan"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
启动程序,进入RingstonActivity就弹出了当前的输入法,本人手机上装的是搜狗输入法
=================================中文大义例如以下=================================
attributes:android:windowSoftInputMode
活动的主窗体怎样与包括屏幕上的软键盘窗体交互。
这个属性的设置将会影响两件事情:
1> 软键盘的状态——是否它是隐藏或显示——当活动(Activity)成为用户关注的焦点。
2> 活动的主窗体调整——是否降低活动主窗体大小以便腾出空间放软键盘或是否当活动窗体的部分被软键盘覆盖时它的内容的当前焦点是可见的。
它的设置必须是以下列表中的一个值,或一个”state…”值加一个”adjust…”值的组合。在任一组设置多个值——多个”state…”values,比如&mdash有没有定义的结果。各个值之间用|分开。比如: <activity android:windowSoftInputMode="stateVisible|adjustResize" . . .
>
在这设置的值(除"stateUnspecified"和"adjustUnspecified"以外)将覆盖在主题中设置的值
以下是这些值的含义:
值 | 含义 |
stateUnspecified | 软键盘的状态(是否它是隐藏或可见)没有被指定。
系统将选择一个合适的状态或依赖于主题的设置。 这个是为了软件盘行为默认的设置。 |
stateUnchanged | 软键盘被保持不管它上次是什么状态,是否可见或隐藏,当主窗体出如今前面时。 |
stateHidden | 当用户选择该Activity时,软键盘被隐藏——也就是,当用户确定导航到该Activity时。而不是返回到它因为离开还有一个Activity。 |
stateAlwaysHidden | 软键盘总是被隐藏的。当该Activity主窗体获取焦点时。 |
stateVisible | 软键盘是可见的,当那个是正常合适的时(当用户导航到Activity主窗体时)。 |
stateAlwaysVisible | 当用户选择这个Activity时。软键盘是可见的——也就是,也就是,当用户确定导航到该Activity时,而不是返回到它因为离开还有一个Activity。 |
adjustUnspecified | 它不被指定是否该Activity主窗体调整大小以便留出软键盘的空间,或是否窗体上的内容得到屏幕上当前的焦点是可见的。系统将自己主动选择这些模式中一种主要依赖于是否窗体的内容有不论什么布局视图可以滚动他们的内容。如果有这种一个视图,这个窗体将调整大小,这种如果可以使滚动窗体的内容在一个较小的区域中可见的。这个是主窗体默认的行为设置。 |
adjustResize | 该Activity主窗体总是被调整屏幕的大小以便留出软键盘的空间。 |
adjustPan | 该Activity主窗体并不调整屏幕的大小以便留出软键盘的空间。相反,当前窗体的内容将自己主动移动以便当前焦点从不被键盘覆盖和用户能总是看到输入内容的部分。这个一般是不期望比调整大小,由于用户可能关闭软键盘以便获得与被覆盖内容的交互操作。 |
欧阳鹏 | http://blog.csdn.net/ouyang_peng |
========================================官网介绍例如以下========================================
语法例如以下:
<activity
android:windowSoftInputMode=["stateUnspecified",
"stateUnchanged", "stateHidden",
"stateAlwaysHidden", "stateVisible",
"stateAlwaysVisible", "adjustUnspecified",
"adjustResize", "adjustPan"] >
android:windowSoftInputMode
- How the main window of the activity interacts with the window containing the on-screen soft keyboard. The setting for this attribute affects two things:
- The state of the soft keyboard — whether it is hidden or visible — when the activity becomes the focus of user attention.
- The adjustment made to the activity's main window — whether it is resized smaller to make room for the soft keyboard or whether its contents pan to make the current focus visible when part of the window is covered by the soft
keyboard.
The setting must be one of the values listed in the following table, or a combination of one "
state...
" value plus one "adjust...
"
value. Setting multiple values in either group — multiple "state...
" values, for example — has undefined results. Individual values are separated by a vertical bar (|
).
For example:<activity android:windowSoftInputMode="stateVisible|adjustResize" . . . >
Values set here (other than "
stateUnspecified
" and "adjustUnspecified
")
override values set in the theme.V alue 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. " 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. " 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. " 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.
noHistory
and windowSoftInputMode
,which were added in API Level 3.
====================================================================================
作者:欧阳鹏 欢迎转载。与人分享是进步的源泉!
转载请保留原文地址:http://blog.csdn.net/ouyang_peng
====================================================================================
我的Android进阶之旅------>Android中android:windowSoftInputMode的使用方法的更多相关文章
- 我的Android进阶之旅------>怎样解决Android 5.0中出现的警告: Service Intent must be explicit:
我的Android进阶之旅-->怎样解决Android 5.0中出现的警告: java.lang.IllegalArgumentException: Service Intent must be ...
- 我的Android进阶之旅------>【强力推荐】Android开源图表库XCL-Charts版本发布及展示页
因为要做图表相关的应用,后来百度发现了一个很好的Android开源图表库(XCL-Charts is a free charting library for Android platform.) 下面 ...
- 【我的Android进阶之旅】如何隐藏Android中EditText控件的默认下划线
Android EditText控件是经常使用的控件,但是有时候我们并不需要它的一些默认的属性,比如说下划线,因为有时候这样的默认下划线看起来特别怪异,和其他控件在一起搭配的时候不协调,因此有时候就需 ...
- 我的Android进阶之旅------>对Java中注释/**@hide*/的初步认识
今天写一个调节系统背光亮度的时候,参考了Android中的Setting源码,在源码中有这么一段代码: private static final int MAXIMUM_BACKLIGHT = and ...
- [置顶] 我的Android进阶之旅------>介绍一款集录制与剪辑为一体的屏幕GIF 动画制作工具 GifCam
由于上一篇文章:我的Android进阶之旅------>Android之动画之Frame Animation实例 中展示的是Frame动画效果,但是之前我是将图片截取下来,不好说明确切的动画过程 ...
- 我的Android进阶之旅------> Android在TextView中显示图片方法
面试题:请说出Android SDK支持哪些方式显示富文本信息(不同颜色.大小.并包括图像的文本信息).并简要说明实现方法. 答案:Android SDK支持例如以下显示富文本信息的方式. 1.使用T ...
- 【我的Android进阶之旅】推荐一款视频转换GIF图片格式的转换工具(Video to GIF)
一.背景 最近想把一些Android Demo的运行效果图获取下来,但是一直使用真机进行调试,在电脑上不好截取一段gif动画.而之前使用模拟器的时候可以使用 GifCam 工具进行屏幕动画截取.Gif ...
- 我的Android进阶之旅------>Android字符串资源中的单引號问题error: Apostrophe not preceded by 的解决的方法
刚刚在string字符串资源文件里,写了一个单引號.报错了,错误代码例如以下 error: Apostrophe not preceded by \ (in OuyangPeng's blog ) 资 ...
- 我的Android进阶之旅------>Android颜色值(#AARRGGBB)透明度百分比和十六进制对应关系以及计算方法
我的Android进阶之旅-->Android颜色值(RGB)所支持的四种常见形式 透明度百分比和十六进制对应关系表格 透明度 十六进制 100% FF 99% FC 98% FA 97% F7 ...
- 我的Android进阶之旅------>解决Jackson等第三方转换Json的开发包在开启混淆后转换的实体类数据都是null的bug
1.错误描述 今天测试人员提了一个bug,说使用我们的app出现了闪退的bug,后来通过debug断点调试,发现我们的app转换服务器发送过来的json数据后,都是为null.而之前已经提测快一个月的 ...
随机推荐
- 【Luogu】P2053修车(费用流)
题目链接 早上状态不好,虚树搞崩只好来刷网络流了qwq. (然后我犹豫几秒之后看了题解) 使用拆点大法把工人拆成n*m个点,然后每个点代表每个时间段的工人, 然后从车到每个工人点连一条边,权值是耽误的 ...
- webstorm自带debugger服务器
打开webstorm->settings->Build,Execution,Deployment->Debugger->把端口Port改成8089或者其他80端口,按确定就可以 ...
- hosts文件位置
windows C:\WINDOWS\system32\drivers\etc mac /etc/hosts 修改hosts文件会遇到无法保存的问题,解法方法参考下文 http://mtoou.inf ...
- 【CF713C】Sonya and Problem Wihtout a Legend(离散化,DP)
题意:给你一个数列,对于每个数字你都可以++或者−− 然后花费就是你修改后和原数字的差值,然后问你修改成一个严格递增的,最小花费 思路:很久以前做过一道一模一样的 严格递增很难处理,就转化为非严格递增 ...
- 【NOIP2016练习】T1 挖金矿(二分答案)
题意: 思路:二分答案A 合法的答案 sigma(s[i][xi])/sigma(xi)>=a i<=m sigma(s[i][xi]-a*xi)>=0 对于每个i找到xi使s[i] ...
- 如果你的css文件这么分类,可维护性大大增强!--摘抄
按照css的性质和用途,我们可以将css文件分成: 公共型样式 特殊型样式 皮肤型样式 并以此为顺序引用. 那么他们分别是什么呢? 公共型样式是最为重要的部分,对于比较小的项目,我们只引入一个css, ...
- jquery 同源跨域请求整理
//同源ajax请求数据 function getData(url,paramjson,fn) { $.ajax({ type : "POST", //提交方式 url : url ...
- Latex algorithm
方式一 需要包含的 \usepackage[noend]{algpseudocode} \usepackage{algorithmicx,algorithm} 源码 \begin{algorithm} ...
- Thread线程的基础知识及常见疑惑点
引言 相信各位道友在平时工作中已经很少直接用到Thread线程类了,现在大多是通过线程池或者一些多线程框架来操作线程任务,但我觉得还是有必要了解清楚Thread线程类中各种方法的含义,了解了底层才能更 ...
- linux grep 查找文件内容
自试: wang@wang:~$ grep -i "*args*" ~/IGV01-SW/src/bzrobot_diagnostics/bzrobot_lightbelt_man ...