笔记90--WindowManager.LayoutParams2.1

发链接:http://blog.csdn.net/hudashi/article/details/7060882

一、WindowManager.LayoutParams的家族关系

其是WindowManager的内部类,extentds ViewGroup.LayoutParams

二、自我介绍

WindowManager.LayoutParams是WindowManager接口的嵌套类,用于向WindowManager描述Window的管理策略。

三、主要成员变量
说几个重要的:
public int x;如果忽略gravity属性,那么它表示窗口的绝对X位置。什么是gravity属性呢?简单说,就是窗口如何停靠。当设置了Gravity.LEFT后,x值就表示到特定边的距离。
public int y;同理。
token是什么?
知道锚吗?可以使船停稳。token就是锚,比如popupwindow设置显示位置时,需要一个token,即先有了锚船才能停。
1、Window Flags系列

主要用于对Window的flag进行设置。设置Window的flag,可以直接对Window的getAttributes()得到其WindowManager.LayoutParams对象,然后直接对其flag变量设置。也可用Window的addFlags(int flags)、setFlags(int flags, int mask)、clearFlags(int flags)进行操作。

1)设置flag

Window win=getWindow();
WindowManager.LayoutParams wp=win.getAttributes();
方式1:wp.flags=wp.flags | WindowManager.LayoutParams.FLAG_FULLSCREEN;
方式2:win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
方式3:win.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

所有Window flag如下:



2、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系列常量如下:


3、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_WINDOWLAST_SUB_WINDOW,

FIRST_SYSTEM_WINDOW , LAST_SYSTEM_WINDOW以表示window的三大类型的取值范围。


4、brightness系列

该系列主要用于设置window的brightness(screenBrightness/buttonBrightness)。可通过WindowManager.LayoutParams的screenBrightness/buttonBrightness变量直接进行设置。

其中screenBrightness表示屏幕的brightness,而buttonBrightness表示一般按键和键盘按键的brightness。


5、changed系列

该系列主要用于int copyFrom(WindowManager.LayoutParams o)函数中。

在函数中,首先将用参数中传入的WindowManager.LayoutParams的信息复制到本WindowManager.LayoutParams中,然后返回一个整数,以bite形式表示调用该函数后WindowManager.LayoutParams的哪些信息发生了变化。


6、继承于ViewGroup.LayoutParams的成员变量


7、自身的成员变量


四、成员函数


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值