我的Android进阶之旅------>Android中android:windowSoftInputMode的用法
来源:互联网 发布:淘宝怎么开好直通车 编辑:程序博客网 时间:2024/06/10 11:31
面试题:如何在显示某个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"以外)将覆盖在主题中设置的值
下面是这些值的含义:
========================================官网介绍如下========================================
语法如下:
<activityandroid: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:drawableLeft的用法
- 我的Android进阶之旅------>Android之进度条(ProgressBar)的功能和用法
- 我的Android进阶之旅------>Android之选项卡(TabHost)的功能和用法
- 我的Android进阶之旅------>Android <requestFocus />标签的用法
- 我的Android进阶之旅------>Android嵌入图像InsetDrawable的用法
- 我的Android进阶之旅------>Android中android:visibility 属性VISIBLE、INVISIBLE、GONE的区别
- android:windowSoftInputMode的说明
- android:windowSoftInputMode的说明
- 我的Android进阶之旅------>ListView中android:cacheColorHint,android:listSelector属性作用 .
- 我的Android进阶之旅------>Android ListView优化详解
- 我的Android进阶之旅------>Android电话窃听实例
- 我的Android进阶之旅------>Android开发错误汇总
- 我的Android进阶之旅------>Android权限参考大全
- 我的Android进阶之旅------>Android拍照小例子
- 我的Android进阶之旅------>Android KeyCode列表
- 我的Android进阶之旅------>Android知识图谱
- 我的Android进阶之旅------>Android知识图谱
- 局部性原理
- POJ 3714 Raid(平面最近点对)
- log4cpp 编译与使用
- Android 屏幕适配
- Windows下使用Beyond Compare作为git的比对与合并工具
- 我的Android进阶之旅------>Android中android:windowSoftInputMode的用法
- java关键字
- Reverse Linked List
- linux程序设计——消息队列(第十四章)
- C中的移位运算
- #29 Divide Two Integers
- 2015071902 - 测试驱动开发 - 01
- 个人复习回顾的mysql相关基础操作
- php mysqli 查询乱码问题