本文大概介绍WindowManager中的LayoutParams主要参数及相关设置,仅供参考。
java.lang.Object | ||
? | android.view.ViewGroup.LayoutParams | |
| ? | android.view.WindowManager.LayoutParams |
主要成员常量
Window flag系列
该系列主要用于对Window的flag进行设置。设置Window的flag,可以直接对Window的getAttributes()得到其 WindowManager.LayoutParams对象,然后直接对它flag变量操作。也可以Window的addFlags(int flags)方法,setFlags(int flags, int mask)方法,clearFlags(int flags)方法进行操作。
比如设置全屏:
Window window = getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
winParams.flags=winParams.flags|WindowManager.LayoutParams.FLAG_FULLSCREEN;
或
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
或
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
取消全屏
Window window = getWindow();
winParams.flags=winParams.flags&~WindowManager.LayoutParams.FLAG_FULLSCREEN;
或
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
或
window.setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
所有Window flag如下:
softInputMode系列
该系列主要用于表示softInputMode,我们可以通过WindowManager.LayoutParams的softInputMode变量直接进行设置。softInputMode只能是一个显示软键盘时的window调整方式bite与一个控制软键盘显示状态的bite的组合。
显示软键盘时的window调整方式可以是SOFT_INPUT_ADJUST_NOTHING,SOFT_INPUT_ADJUST_PAN,
SOFT_INPUT_ADJUST_RESIZE,SOFT_INPUT_ADJUST_UNSPECIFIED之一。
用于描述软键盘显示的规则可以是SOFT_INPUT_STATE_ALWAYS_HIDDEN,SOFT_INPUT_STATE_ALWAYS_VISIBLE,
SOFT_INPUT_STATE_HIDDEN,SOFT_INPUT_STATE_VISIBLE,SOFT_INPUT_STATE_UNSPECIFIED之一
关于softInputMode的更多知识请参考《软件盘的开关》
所有的softInputMode系列常量如下:
Window type系列
该系列主要用于表示window的类型。我们可以通过WindowManager.LayoutParams的type变量直接进行设置.
window 的类型被分为了3大类:
Application windows (ranging from FIRST_APPLICATION_WINDOW to LAST_APPLICATION_WINDOW) are normal top-level application windows. For these types of windows, the token must be set to the token of the activity they are a part of (this will normally be done for you if token is null).
Sub-windows (ranging from FIRST_SUB_WINDOW to LAST_SUB_WINDOW) are associated with another top-level window. For these types of windows, the token must be the token of the window it is attached to.
System windows (ranging from FIRST_SYSTEM_WINDOW to LAST_SYSTEM_WINDOW) are special types of windows for use by the system for specific purposes. They should not normally be used by applications, and a special permission is required to use them.
系统专门定义了FIRST_APPLICATION_WINDOW , LAST_APPLICATION_WINDOW,FIRST_SUB_WINDOW, LAST_SUB_WINDOW,
FIRST_SYSTEM_WINDOW,LAST_SYSTEM_WINDOW 以表示window的3大类型的类型的取值的范围。
http://blog.csdn.net/hudashi/article/details/7060882