Android的图形用户界面的体系结构 - 表层/视图/窗口/画布之间的关​​系画布、表层、体系结构、视图

2023-09-04 08:02:45 作者:抱着猫睡觉

=========================

更新:经过几天的google搜索和实验的,我已经找到了答案大多那些愚蠢的问题。见我提交的答案。

=========

Android是什么窗口的责任?

这里有一些问题:

在它是负责收集和分发的输入? 什么是视图和窗口之间的关系?相同DFB表面和窗口之间的关系? 什么是活动和窗口之间的关系?将每个活动都有一个窗口? 是否有可能创建应用程序的窗口?而当有必要吗? 在是否支持Android多窗口?

编辑:添加更多的问题:

什么是各种类的责任,如窗口,查看,画布,表面和它们彼此如何合作?

多少个窗口通常是一个活动呢?

3.Will在一个活动的所有意见将被附加到窗口? 什么是附加意思?

每个窗口都具有表面?每个画布都有面?

查看负责聚焦/的keyEvent /经理,而高弓足只负责拉操作。

窗口管理器负责窗口堆叠?这是如何与相关SurfaceFlinger?

查看没有自己的面,查看包含窗口拥有?

在视图中绘制本身使用的帆布致电surface.lockCanvas()了。

在的OnDraw(画布)将被调用?如何与放大器;谁通过画布参数?

画布是否有大小?将窗口的表面总是全屏?

再次编辑:

看着被罗曼盖伊http://www.youtube.com/watch?v=duefsFTJXzc&feature=feedwll&list=WL ,有几个问题都解决了,并添加几个:)

会在每次活动都有一个的ViewRoot和因此,一个窗口? 是否有任何需要显式地创建一个窗口?并且将表面的窗口永远是全屏? 威尔状态栏在另一个窗口? 什么是表面的大小?这会否永远是全屏幕? 解决方案   

时的窗口负责收集和分发的输入?

没有。的ViewRoot负责这个。

  

有什么看法和窗口之间的关系?相同   在DFB表面和窗之间的关系?

  

是什么活动和窗口之间的关系?将每个活动都有一个窗口?

是的,大部分时间。然而,一个SurfaceView有其自己的窗口。所以,如果一个活动具有SurfaceView它将有一个以上的窗口。

  

是否有可能创建应用程序的窗口?而当有必要吗?

没有必要的。

  

是否支持Android多窗口?

当然。使用HierachyView可以清楚地看到,有多个窗口存在于系统中。

  

1.什么是各种类别,如窗口查看的责任帆布表面,以及它们如何相互协作?   2.How许多窗口通常是一个活动有哪些?

通常之一。

  

3.Will在一个活动的所有意见将被连接到一个窗口?什么是连接呢?   每是否清晰可辨窗口有一个表面?是否每个帆布具有表面?

每个窗口都有一个表面和表面使用画布绘制表面上。

  

5.View负责管理的重点/关键事件,而帆布只负责拉操作?

  

6 窗口管理器负责窗口堆叠?如何,涉及到 SurfaceFlinger

不确定的窗口管理的责任。 (TODO)

SurfaceFlinger 可用于在一个与不同的窗口/活动相关联的表面。

  

7.View没有自己的面,查看包含窗口拥有?

查看会在表面采用帆布画。视图被附着到窗拥有的表面上。

这可以通过实现一个自定义视图,当你应该重写的OnDraw(画布)方法在派生类中被理解。

  

8.查看使用绘制的帆布拨打了自己surface.lockCanvas()?

YES。

  

9,当又是怎样的的OnDraw(画布)叫,谁通过画布参数?

的OnDraw()将由 RootView 打来电话,无效时被调用。画布参数从RootView传递

  

10.Does画布的尺寸?将一个窗口的表面总是全屏?

我不能肯定地说。但是,当我创建一个自定义视图,画布的大小从的OnDraw(画布)得到的是整个屏幕。

不过,在我的理解,对性能的缘故,表面为窗口不应该总是充满屏幕。但是这个假设并没有得到证实。例如,状态栏窗口不应该是全屏。

  

1.Will每个活动有一个的ViewRoot ,因此一个窗口

  

2.Is有任何需要显式地创建一个窗口?请问面为窗口永远是全屏?

没有必要明确地创建窗口本身。

  

3.Will状态栏在另一个窗口?

YES。

  

4.什么是表面的大小?这会否永远是全屏?

=========================

UPDATE: After several days googling and experiments, I have found the answers for most of those dumb questions. See the answers I submitted.

=========

What is the responsibility of Android Window?

Here are some questions:

Is it responsible for collecting and dispatching the input? What is the relationship between the view and window? Same as the relationship between surface and window in DFB? What is the relationship between an activity and window? Will each Activity has a window? Is it possible to create a window from application ? And when it is necessary? Does Android support multi-window?

EDIT: Add more questions:

What is responsibilities of various class , such as Window, View, Canvas, Surface and how they collaborate with each other?

How many windows usually an Activity have?

3.Will all the views in one Activity will be attached to Window? What does attach mean?

Every window have surface? Every Canvas has surface?

View is responsible for focus/keyEvent/ manager, while Cavus is only responsible for "drawing" operation.

WindowManager is responsible for Window stacking? How that is related with SurfaceFlinger?

View doesn't own a Surface , the Window the view contained owns?

The View draw itself using canvas got by calling surface.lockCanvas().

When onDraw(Canvas) will be called? How & who pass the canvas parameters?

Does Canvas has size? Will Window's surface always be full screen?

EDIT again:

After watching this wonderful presentatin provided by Romain Guy http://www.youtube.com/watch?v=duefsFTJXzc&feature=feedwll&list=WL , several questions are resolved and add several more :)

Will every Activity has one ViewRoot and thus one Window? Is there any need to create a window explictly? and Will the surface for the window always be full screen? Will status bar be in another Window? What is the size of the surface? Will that always be full screen?

解决方案

Is Window responsible for collecting and dispatching the input?

No. ViewRoot is responsible for this.

What is the relationship between the view and window? Same as the relationship between surface and window in DFB?

?

What is the relationship between an activity and window? Will each activity have a window?

Yes, most of the time. However, a SurfaceView has its own window. So, if an Activity has a SurfaceView it will have more than one Window.

Is it possible to create a window from application? And when it is necessary?

Not necessary.

Does Android support multi-window?

Sure. Using HierachyView you can clearly see that there is more than one Window exists in the system.

1.What are the responsibilities of various classes, such as Window, View, Canvas, Surface, and how do they collaborate with each other? 2.How many windows usually an Activity have?

Usually one.

3.Will all the views in one Activity will be attached to a window? What does attach mean? 4.Does every window have a surface? Does every canvas have a surface?

Every Window has a surface and Surface uses Canvas to draw on the surface.

5.View is responsible for managing focus/key events, while Canvas is only responsible for "drawing" operation?

YES.

6.WindowManager is responsible for Window stacking? How does that relate to SurfaceFlinger?

Not Sure of WindowManager's responsibility. (TODO)

SurfaceFlinger is used to compose the Surface that is associated with different Window/Activity.

7.View doesn't own a Surface, the Window the view contained owns?

View will draw on surface using Canvas. The window the view is attached to owns the surface.

This could be understood by implement a customize view, when you should override the onDraw(Canvas) method in your derived class.

8.The View draws itself using canvas got by calling surface.lockCanvas()?

YES.

9.When and how is onDraw(Canvas) called, and who passes the canvas parameters?

onDraw() will be called by the RootView and when invalidate is called. The canvas parameter is passed from the RootView.

10.Does Canvas have a size? Will a Window's surface always be full screen?

I cannot say for sure. But when I create a customize view, the size of the canvas got from onDraw(Canvas) is full screen.

However, in my understanding, for performance sake, the Surface for the window should not always be full screen. But this assumption has not been verified. For example, the statusBar window should not be full screen.

1.Will every Activity have one ViewRoot and thus one Window?

YES.

2.Is there any need to create a window explicitly? Will the surface for the window always be full screen?

No need to create the Window explicitly per se.

3.Will status bar be in another Window?

YES.

4.What is the size of the surface? Will that always be full screen?