android复杂的概念,经常会弄的人晕头转向.本篇说说ui里几个概念的关系.

1. 从activity启动流程,可以看出各个对象的关系

大家都知道,这是android ui的核心概念.收的就是界面的一个活动交互界面.用startAcvitity的方式启动.省去中间状态:

在activity的attach接口中:

5063         mWindow = PolicyManager.makeNewWindow(this); 每个activity有一个Window对象.  5064         mWindow.setCallback(this);  设置window对象的回调是activity  5087         mWindow.setWindowManager(   设置window对象的manager  5088                 (WindowManager)context.getSystemService(Context.WINDOW_SERVICE),  5089                 mToken, mComponent.flattenToString(),  5090                 (info.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0);  5091         if (mParent != null) {  5092             mWindow.setContainer(mParent.getWindow());  5093         }  5094         mWindowManager = mWindow.getWindowManager(); 保存windowmanager

在ActivityThread的handleResumeActivity接口里:

  2796                 r.window = r.activity.getWindow();  2797                 View decor = r.window.getDecorView(); decorview是window子类, 通过window来获取  2798                 decor.setVisibility(View.INVISIBLE);  2799                 ViewManager wm = a.getWindowManager();  2800                 WindowManager.LayoutParams l = r.window.getAttributes();  2801                 a.mDecor = decor;  给activity的mDecor赋值             2804                 if (a.mVisibleFromClient) {  2805                     a.mWindowAdded = true;  2806                     wm.addView(decor, l);  这个调用会调用到WindowManagerGlobal的addView  2807                 }

WindowManagerGlobal的addView会

16             root = new ViewRootImpl(view.getContext(), display);6              root.setView(view, wparams, panelParentView);

也就是说, ViewRootImpl的mView其实是DecorView.

2.   总结

每个activity有个window,window被windowmanager管理.

每个window都有decorview.

每个window都有ViewRoot.

绘制发起从ViewRoot.

事件传递发起冲ViewRoot.

绘制传递canvas, canvas来自surface.


更多相关文章

  1. 家庭版记账本app进度之关于android界面布局的相关学习
  2. Android(安卓)聊天界面对话
  3. 关于Android中传递数据的一些讨论
  4. android 退出整个程序
  5. Android(安卓)6.0 之AlarmManagerService源码分析
  6. Android(安卓)Asynchronous Http Client-Android异步网络请求客
  7. 探索Android该Parcel机制上
  8. Android(安卓)性能分析案例
  9. 探索Android该Parcel机制(上)

随机推荐

  1. Android 6.0+新的运行时权限 开发者需要
  2. 打造android ORM框架opendroid(七)——数
  3. Android不同版本功能升级汇总
  4. android 系统核心机制binder(01)C语言简谈b
  5. Android中文API合集(6) + 开发者指南合集
  6. android service 学习(下)
  7. Ant编译编译APK、打包打包JS
  8. Android(安卓)高级UI 目录
  9. Icon Font --Android图标也能轻松换肤
  10. 【Android】Android输入子系统