最近在做开发的时候遇到个比较烦的问题就是 我的某个activity页面中有editText,在一进去就会调用软键盘,这样看起来不美观,所以看了下api

 http://developer.android.com/guide/topics/manifest/activity-element.html(要×××)

 

    在<Activity>节点下也就是在manifest文件的配置activity节点的时候需要配置

android:windowSoftInputMode 这个属性来控制软键盘的模式。我摘录了一下api  相关软键盘的片段如下:

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 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.

    ValueDescription
    "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.

     

    浏览了下大概了解下也就是说这个配置主要是做两件事请

    1、当activity获取焦点的时候来设置软键盘是否可见。

    2、(在软键盘变小的时候留出空间,或者activity包含一个软键盘布局同时这个activity获取焦点的时候【pan 在这里翻译的应该是面板,学过java GUI 的都知道有个panle】)调整以适应activity 的大小。

    同时这有很多独立的属性可以去设置,如果你想要设置的属性在其中没有的话你可以尝试着用以上的属性组合一下,只要组合的时候用“|”分开就好了。

  • 跑题了 ,我们要的效果是在当前的activity中有edittext,但是默认不弹出,只有当获取焦点的时候才弹出软键盘,那么我们根据属性可以看下

adjustUnspecified | stateHidden 这个组合起来应该可以达到我们要的效果。因此我们在activity的节点上配置入下:< Activity   android:windowSoftInputMode="stateHidden|adjustUnspecified">

其他的效果可以根据api文档说明进行设置。

 英语水平有限,欢迎指正错误 
 /**
 *
 *  
 **/