WindowManager.LayoutParams 是 WindowManager 接口的嵌套类;继承于 ViewGroup.LayoutParams 。
它的内容十分丰富。其实WindowManager.java的主要内容就是由这个类定义构成。下面来分析一下这个类:
定义
public static class WindowManager.LayoutParams extends ViewGroup.LayoutParams implements Parcelable
继承关系
java.lang.Object
android.view.ViewGroup.LayoutParams
android.view.WindowManager.LayoutParams
继承来的属性与常量
从ViewManager.LayoutParams 继承来的属性:
android:layout_height
Specifies the basic height of the view.
android:layout_width
Specifies the basic width of the view.
从ViewManager.LayoutParams继承的常量:
FILL_PARENT
WRAP_CONTENT
MATCH_PARENT
两个变量:
width
height
属性及可用的常量定义
1. public int x;
如果忽略gravity属性,那么它表示窗口的绝对X位置。
什么是gravity属性呢?简单地说,就是窗口如何停靠。
当设置了 Gravity.LEFT 或 Gravity.RIGHT 之后,x值就表示到特定边的距离。
2. public int y;
如果忽略gravity属性,那么它表示窗口的绝对Y位置。
当设置了 Gravity.TOP 或 Gravity.BOTTOM 之后,y值就表示到特定边的距离。
3. public float horizontalWeight;
public float verticalWeight;
在纵/横向上,为关联的view预留了多少扩展空间(像素)。如果是0,那么此view不能被拉伸。
其他情况下,扩展空间(像素)将被widget所均分。
4. public int type;
窗口类型。
有3种主要类型:
Applicationwindows:
取值在 FIRST_APPLICATION_WINDOW 和 LAST_APPLICATION_WINDOW 之间。
是通常的、顶层的应用程序窗口。必须将 token 设置成 activity 的 token 。
Sub_windows:
取值在 FIRST_SUB_WINDOW 和 LAST_SUB_WINDOW 之间。
与顶层窗口相关联,token 必须设置为它所附着的宿主窗口的 token。
Systemwindows:
取值在 FIRST_SYSTEM_WINDOW 和 LAST_SYSTEM_WINDOW 之间。
用于特定的系统功能。它不能用于应用程序,使用时需要特殊权限。
下面定义了 type 的取值:
java代码:
系列之Android 说说WindowManager.LayoutParams类(二)的帖子链接
http://www.eoeandroid.com/thread-84921-1-1.html
系列之Android 说说WindowManager.LayoutParams类(三)的帖子链接
http://www.eoeandroid.com/thread-84922-1-1.html
它的内容十分丰富。其实WindowManager.java的主要内容就是由这个类定义构成。下面来分析一下这个类:
定义
public static class WindowManager.LayoutParams extends ViewGroup.LayoutParams implements Parcelable
继承关系
java.lang.Object
android.view.ViewGroup.LayoutParams
android.view.WindowManager.LayoutParams
继承来的属性与常量
从ViewManager.LayoutParams 继承来的属性:
android:layout_height
Specifies the basic height of the view.
android:layout_width
Specifies the basic width of the view.
从ViewManager.LayoutParams继承的常量:
FILL_PARENT
WRAP_CONTENT
MATCH_PARENT
两个变量:
width
height
属性及可用的常量定义
1. public int x;
如果忽略gravity属性,那么它表示窗口的绝对X位置。
什么是gravity属性呢?简单地说,就是窗口如何停靠。
当设置了 Gravity.LEFT 或 Gravity.RIGHT 之后,x值就表示到特定边的距离。
2. public int y;
如果忽略gravity属性,那么它表示窗口的绝对Y位置。
当设置了 Gravity.TOP 或 Gravity.BOTTOM 之后,y值就表示到特定边的距离。
3. public float horizontalWeight;
public float verticalWeight;
在纵/横向上,为关联的view预留了多少扩展空间(像素)。如果是0,那么此view不能被拉伸。
其他情况下,扩展空间(像素)将被widget所均分。
4. public int type;
窗口类型。
有3种主要类型:
Applicationwindows:
取值在 FIRST_APPLICATION_WINDOW 和 LAST_APPLICATION_WINDOW 之间。
是通常的、顶层的应用程序窗口。必须将 token 设置成 activity 的 token 。
Sub_windows:
取值在 FIRST_SUB_WINDOW 和 LAST_SUB_WINDOW 之间。
与顶层窗口相关联,token 必须设置为它所附着的宿主窗口的 token。
Systemwindows:
取值在 FIRST_SYSTEM_WINDOW 和 LAST_SYSTEM_WINDOW 之间。
用于特定的系统功能。它不能用于应用程序,使用时需要特殊权限。
下面定义了 type 的取值:
java代码:
系列之Android 说说WindowManager.LayoutParams类(二)的帖子链接
http://www.eoeandroid.com/thread-84921-1-1.html
系列之Android 说说WindowManager.LayoutParams类(三)的帖子链接
http://www.eoeandroid.com/thread-84922-1-1.html