Page does not rise with soft keyboard and Android hidden soft keyboard summary _android

Source: Internet
Author: User

Is in the configuration file corresponding to the activity plus this sentence: android:windowsoftinputmode= "Statevisible|adjustresize"

After setting

Introduction to Android:windowsoftinputmode Properties

Android:windowsoftinputmode

The interaction mode between the main activity window and the soft keyboard can be used to avoid the problem of the Input Panel occlusion and a new feature after Android1.5.

This property affects two things:

"One" when the focus is generated, the soft keyboard is hidden or displayed
"Two" reduces the active main window size to make room for soft keyboard
Its setting must be a value in the following list, or a combination of a "state ..." value plus a "adjust ..." value. Set multiple values in either group-multiple "state ..." values such as &mdash have undefined results. Each value is separated by | For example:

The values set here (except "stateunspecified" and "adjustunspecified") override the values set in the theme

Meaning of each value:

"A" stateunspecified: the state of the soft keyboard is not specified, the system will choose a suitable state or dependent on the theme of the settings
"B" stateunchanged: When this activity appears, the soft keyboard will remain in the previous activity, whether hidden or displayed
"C" Statehidden: When a user chooses an activity, the soft keyboard is always hidden
"D" Statealwayshidden: When the Activity main window gets the focus, the soft keyboard is always hidden
"E" statevisible: Soft keyboards are usually visible
"F" statealwaysvisible: When a user chooses an activity, the soft keyboard always shows the state
"G" adjustunspecified: Default settings, usually determined by the system to hide or show
"H" adjustresize: The activity always adjusts the size of the screen to allow space for the soft keyboard
"I" Adjustpan: The contents of the current window will automatically move so that the current focus is never covered by the keyboard and the user can always see the part of the input

About Android Soft Keyboard Hide Summary

1> the state of the soft keyboard--hidden or displayed.

One: Automatically eject soft keyboard

Timetimer=netimer (
timer.schedule (netimertask
publivoirun
inputmethodmanageinputmethodmanager= ( Inputmethodmanagergetsystemservice (Context.input_method_service
inputmethodmanager.togglesoftinput ( Inputmethodmanager.hide_not_always
}

Two: Soft keyboard

In Activity settings:

Android:windowsoftinputmode= "stateunspecified", default setting: The state of the soft keyboard (hidden or visible) is not specified. The system will select an appropriate state or a theme-dependent setting.

"Stateunchanged", the soft keyboard is kept in the last state. "Statehidden", when the user selects the activity, the soft keyboard is hidden.

"Statealwayshidden", the soft keyboard is always hidden.

"Statevisible",. The soft keyboard is visible.

"Statealwaysvisible", when the user chooses this activity, the soft keyboard is visible.

"Adjustunspecified",. It is not specified whether the active main window is resized to leave the soft keyboard space, or whether the contents of the window are visible on the screen where the current focus is. The system will automatically select one of these modes that is primarily dependent on whether the contents of the window have any layout view to scroll their content. If you have such a view, the window will resize so that the contents of the scrolling window are visible in a smaller area. This is the default behavior setting for the main window.                                        In other words, the system automatically determines whether to use the translation mode or compression mode, the determining factor is the content can be scrolled. "Adjustresize" (compressed mode) when the soft keyboard pops up, adjust the size of the screen to the main window to leave the soft keyboard space. "Adjustpan" > (Pan Mode: When the input box is not blocked, the pattern does not adjust the layout, but when the input box will be blocked, the window will be translated.) That is, the pattern is always to keep the input box visible ...

Three: Hide the soft keyboard:

EditText edit= (EditText) Findviewbyid (r.id.edit); 
      Inputmethodmanager IMM = (inputmethodmanager) getsystemservice (context.input_method_service); 
      Imm.hidesoftinputfromwindow (Edit.getwindowtoken (), 0);

4.EditText default does not eject software keyboard

Method One:

Select which activity in the Androidmainfest.xml and set the Windowsoftinputmode property to Adjustunspecified|statehidden

For example: <activity android:name= ". Main "

    Android:label= "@string/app_name"
         android:windowsoftinputmode= "Adjustunspecified|statehidden"
         Android: configchanges= "Orientation|keyboardhidden" >
      <intent-filter>
        <action android:name= " Android.intent.action.MAIN "/>
        <category android:name= android.intent.category.LAUNCHER"/>
      < /intent-filter>
    </activity>

Method Two:

Let EditText lose focus, use the EditText Clearfocus method

For example: EditText edit= (EditText) Findviewbyid (R.id.edit);

Edit.clearfocus ();

Method Three:

Force hide the Android Input Method window

For example: EditText edit= (EditText) Findviewbyid (R.id.edit);

Inputmethodmanager IMM = (inputmethodmanager) getsystemservice (context.input_method_service); 
      Imm.hidesoftinputfromwindow (Edit.getwindowtoken (), 0);

5.EditText always does not eject the software keyboard

Example: EditText edit= (EditText) Findviewbyid (R.id.edit);

 Edit.setinputtype (Inputtype.type_null);

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.