什么是LayoutInflater attachToRoot参数是什么意思? [英] What does the LayoutInflater attachToRoot parameter mean?

查看:440
本文介绍了什么是LayoutInflater attachToRoot参数是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的<一个href="http://developer.android.com/reference/android/view/LayoutInflater.html#inflate%28org.xmlpull.v1.XmlPullParser,%20android.view.ViewGroup,%20boolean%29"><$c$c>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).

这篇关于什么是LayoutInflater attachToRoot参数是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆