android 设置View
16lz
2021-01-23
回去window属性
WindowManager.LayoutParams l = r.window.getAttributes();
Decor 为PhoneWindow.DecorView 这个View其实是一个Activity 的最底层View
wm.addView(decor, l);
调用PhoneWindow的LocalWindowManager 中的addView
调用 WindowManagerImpl 的addView
进一步调用如下方法:
ViewRoot里面也有一个Window Attribute变量mWindowAttributes ---Window
attrs 为Window的Attribute mWindowAttributes.copyFrom(attrs);--ViewRoot
这是两个不同的对象,有时间内容相同。 具体看代码。
WindowManager.LayoutParams l = r.window.getAttributes();
Decor 为PhoneWindow.DecorView 这个View其实是一个Activity 的最底层View
wm.addView(decor, l);
调用PhoneWindow的LocalWindowManager 中的addView
public final void addView(View view, ViewGroup.LayoutParams params) { // Let this throw an exception on a bad params. WindowManager.LayoutParams wp = (WindowManager.LayoutParams)params; CharSequence curTitle = wp.getTitle(); if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW && wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { if (wp.token == null) { View decor = peekDecorView(); if (decor != null) { wp.token = decor.getWindowToken(); } } if (curTitle == null || curTitle.length() == 0) { String title; if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) { title="Media"; } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) { title="MediaOvr"; } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { title="Panel"; } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) { title="SubPanel"; } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) { title="AtchDlg"; } else { title=Integer.toString(wp.type); } if (mAppName != null) { title += ":" + mAppName; } wp.setTitle(title); } } else { if (wp.token == null) { wp.token = mContainer == null ? mAppToken : mContainer.mAppToken; } if ((curTitle == null || curTitle.length() == 0) && mAppName != null) { wp.setTitle(mAppName); } } if (wp.packageName == null) { wp.packageName = mContext.getPackageName(); } mWindowManager.addView(view, params); }
调用 WindowManagerImpl 的addView
进一步调用如下方法:
final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams)params;root.setView(view, wparams, panelParentView);
ViewRoot里面也有一个Window Attribute变量mWindowAttributes ---Window
attrs 为Window的Attribute mWindowAttributes.copyFrom(attrs);--ViewRoot
这是两个不同的对象,有时间内容相同。 具体看代码。
更多相关文章
- Android View measure (五) 支持margin属性,从一个异常说起
- java android maven环境变量基本配置
- Android Banner属性设置
- Android 用属性动画自定义view的渐变背景
- android 属性动画之 ObjectAnimator
- android makefile 常用宏名称和内置变量
- Android 设置对话框中的确定按钮的 enabled 属性
- android 设置activity通用的全局变量(新手必备)