什么是LayoutInflater attachToRoot参数是什么意思?参数、LayoutInflater、attachToRoot

由网友(痴.)分享简介:的LayoutInflater.inflate文档是不完全清楚,我对 attachToRoot 参数的目的。 attachToRoot 的:膨胀的层级是否应附加到根参数?如果为假,根仅用于创建正确的子类的LayoutParams在XML根视图。attachToRoot: whether the inflated hie...

的LayoutInflater.inflate文档是不完全清楚,我对 attachToRoot 参数的目的。

attachToRoot 的:膨胀的层级是否应附加到根参数?如果为假,根仅用于创建正确的   子类的LayoutParams在XML根视图。

attachToRoot: whether the inflated hierarchy should be attached to the root parameter? If false, root is only used to create the correct subclass of LayoutParams for the root view in the XML.

可能有人请详细解释,具体是什么的根本观点是,也许表现出行为的变化之间的示例值?

Could someone please explain in more detail, specifically what the root view is, and maybe show an example of a change in behavior between true and false values?

推荐答案

如果设置为true,那么当你的布局膨胀将被自动添加到的ViewGroup中的第二个参数作为一个孩子指定的视图层次结构。例如,如果根参数是一个的LinearLayout 那么你的放大视图将被自动添加为视图的孩子。

If set to true then when your layout is inflated it will be automatically added to the view hierarchy of the ViewGroup specified in the 2nd parameter as a child. For example if the root parameter was a LinearLayout then your inflated view will be automatically added as a child of that view.

如果它被设置为false,那么你的布局会膨胀,但不会被连接到任何其他的布局(这样就不会被绘制,接收触摸事件等)。

If it is set to false then your layout will be inflated but won't be attached to any other layout (so it won't be drawn, receive touch events etc).

阅读全文

相关推荐

最新文章