FileDocCategorySizeDatePackage
SoftInputWindow.javaAPI DocAndroid 1.5 API5440Wed May 06 22:41:54 BST 2009android.inputmethodservice

SoftInputWindow

public class SoftInputWindow extends android.app.Dialog
A SoftInputWindow is a Dialog that is intended to be used for a top-level input method window. It will be displayed along the edge of the screen, moving the application user interface away from it so that the focused item is always visible.

Fields Summary
Constructors Summary
public SoftInputWindow(android.content.Context context, int theme)
Create a DockWindow that uses a custom style.

param
context The Context in which the DockWindow should run. In particular, it uses the window manager and theme from this context to present its UI.
param
theme A style resource describing the theme to use for the window. See Style and Theme Resources for more information about defining and using styles. This theme is applied on top of the current theme in context. If 0, the default dialog theme will be used.

        super(context, theme);
        initDockWindow();
    
Methods Summary
public intgetSize()
Get the size of the DockWindow.

return
If the DockWindow sticks to the top or bottom of the screen, the return value is the height of the DockWindow, and its width is equal to the width of the screen; If the DockWindow sticks to the left or right of the screen, the return value is the width of the DockWindow, and its height is equal to the height of the screen.

        WindowManager.LayoutParams lp = getWindow().getAttributes();

        if (lp.gravity == Gravity.TOP || lp.gravity == Gravity.BOTTOM) {
            return lp.height;
        } else {
            return lp.width;
        }
    
private voidinitDockWindow()

        WindowManager.LayoutParams lp = getWindow().getAttributes();

        lp.type = WindowManager.LayoutParams.TYPE_INPUT_METHOD;
        lp.setTitle("InputMethod");

        lp.gravity = Gravity.BOTTOM;
        lp.width = -1;
        // Let the input method window's orientation follow sensor based rotation
        // Turn this off for now, it is very problematic.
        //lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER;

        getWindow().setAttributes(lp);
        getWindow().setFlags(
                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    
public voidsetGravity(int gravity)
Set which boundary of the screen the DockWindow sticks to.

param
gravity The boundary of the screen to stick. See {#link android.view.Gravity.LEFT}, {#link android.view.Gravity.TOP}, {#link android.view.Gravity.BOTTOM}, {#link android.view.Gravity.RIGHT}.

        WindowManager.LayoutParams lp = getWindow().getAttributes();

        boolean oldIsVertical = (lp.gravity == Gravity.TOP || lp.gravity == Gravity.BOTTOM);

        lp.gravity = gravity;

        boolean newIsVertical = (lp.gravity == Gravity.TOP || lp.gravity == Gravity.BOTTOM);

        if (oldIsVertical != newIsVertical) {
            int tmp = lp.width;
            lp.width = lp.height;
            lp.height = tmp;
            getWindow().setAttributes(lp);
        }
    
public voidsetSize(int size)
Set the size of the DockWindow.

param
size If the DockWindow sticks to the top or bottom of the screen, size is the height of the DockWindow, and its width is equal to the width of the screen; If the DockWindow sticks to the left or right of the screen, size is the width of the DockWindow, and its height is equal to the height of the screen.

        WindowManager.LayoutParams lp = getWindow().getAttributes();

        if (lp.gravity == Gravity.TOP || lp.gravity == Gravity.BOTTOM) {
            lp.width = -1;
            lp.height = size;
        } else {
            lp.width = size;
            lp.height = -1;
        }
        getWindow().setAttributes(lp);
    
public voidsetToken(android.os.IBinder token)

        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.token = token;
        getWindow().setAttributes(lp);