Soft Keyboard settings

Source: Internet
Author: User

If edittext is used for text input without special settings, the android-Based Soft Keyboard will occupy the entire interface. How can I make the keyboard only occupy part of the screen?

XML Code
    1. <Edittext
    2. Android: ID="@ + ID/text1"
    3. Android: layout_width="150dip"
    4. Android: layout_height="Wrap_content"
    5. Android: imeoptions="Flagnoextractui"/>

You can use Android: imeoptinos to set some interface settings for the keyboard that comes with Android:

Java code
  1. Android: imeoptions ="Flagnoextractui"// Disable full screen display on the keyboard. only part of the screen is occupied.
  2. At the same time, this property also controls the display content of the buttons in the lower right corner of the soft keyboard, which is the return key by default.
  3. Android: imeoptions ="Actionnone"// No prompt is displayed on the right of the input box.
  4. Android: imeoptions ="Actiongo"// The content of the button in the lower right corner is 'start'
  5. Android: imeoptions ="Actionsearch"// Click the button in the lower-right corner to search for a magnifier image.
  6. Android: imeoptions ="Actionsend"// The button content in the lower right corner is 'send'
  7. Android: imeoptions ="Actionnext"// The button content in the lower right corner is 'Next'
  8. Android: imeoptions ="Actiondone"// The button content in the lower right corner is 'complete'

At the same time, you may add the corresponding listener to edittext to capture the listening event that the user clicks the button in the lower right corner of the soft keyboard for processing.

Java code
  1. Edittext. setoneditexceptionlistener (NewOneditexceptionlistener (){
  2. @ Override
  3. Public BooleanOneditequaltion (textview V,IntActionid, keyevent event ){
  4. Toast. maketext (mainactivity.This,"Text2", Toast. length_short). Show ();
  5. Return False;
  6. }
  7. });

Soft input mode options:
Public int softinputmode;

The following options are related to the input mode:
Whether the soft input area is visible.
Public static final int soft_input_mask_state = 0x0f;

The status is not specified.
Public static final int soft_input_state_unspecified = 0;

Do not modify the status of the soft input area.
Public static final int soft_input_state_unchanged = 1;

Hide the Input Method Area (when the user enters the window ).
Public static final int soft_input_state_hidden = 2;

When the window gets focus, the input method area is hidden.
Public static final int soft_input_state_always_hidden = 3;

Display the Input Method Area (when the user enters the window ).
Public static final int soft_input_state_visible = 4;

When the window gets focus, the input method area is displayed.
Public static final int soft_input_state_always_visible = 5;

The window should be adjusted to adapt to the soft input window.
Public static final int soft_input_mask_adjust = 0xf0;

If the status is not specified, the system will try to select an input method style based on the window content.
Public static final int soft_input_adjust_unspecified = 0x00;

When the input method is displayed, the window size can be re-calculated so that the content is not overwritten by the input method.
It cannot be used together with soft_input_adjusp_pan. If neither of them is set, the system automatically sets an option based on the window content.
Public static final int soft_input_adjust_resize = 0x10;

Translation window when the input method is displayed. It does not need to handle size changes. The frame can move the window to ensure that the input focus is visible.
It cannot be used together with soft_input_adjust_resize. If neither of them is set, the system automatically sets an option based on the window content.
Public static final int soft_input_adjust_pan = 0x20;

When you go to this window, it is automatically set by the system, so do not set it.
This flag is automatically cleared when the window is displayed.
Public static final int soft_input_is_forward_navigation = 0x100;

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.