什么是使用"附着于根"在布局气筒?气筒、布局、QUOT

2023-09-06 09:00:03 作者:相信自已

我是新手到Android,我知道这个问题已经被问,但我不能得到令人满意的解释。 我的疑惑是:

I am a newbie to android, I know this question has already been asked but i couldn't get a satisfactory explanation. My doubts are:

什么是附加到根的用途,如果可能的话用小 和明显的例子。 当我寻找答案的人表示,其可选的用于 附加到父视图组,视图组层次结构是什么?(是 我们创建编程或者是在考虑的意见 同时考虑到在一个XML文件中已声明的看法) What is "attach to root" used for, if possible with a small and clear example. When I searched for the answer people said its optional used to attach to parent view group, What is the view group hierarchy?(Is that considering views that we created programatically or is that also considering the views that are already declared in an xml file)

我希望这些问题是清楚的,如果不是,请说出来的意见。

I hope the questions is clear, if not please say so in the comments.

推荐答案

我自己也搞不清楚是什么 attachToRoot 的真正目的充气方法。经过一番UI的学习,我终于得到了答案:

I myself was also confused about what was the real purpose of attachToRoot in inflate method. After a bit of UI study, I finally got the answer:

父:​​

在这种情况下是widget /布局是围绕您要使用findViewById(),膨胀的视图对象

in this case is the widget/layout that is surrounding the view objects that you want to inflate using findViewById().

attachToRoot:

连接到他们的父母的意见(包括它们的父层次),所以任何触摸事件的看法免费获赠也将转移到父视图。现在是高达父母是否愿意来招待这些事件或忽略它们。如果设置为false,不会被添加作为母公司直接孩子和家长不从的意见,接受她的任何触摸事件。

attaches the views to their parent (includes them in the parent hierarchy), so any touch event that the views recieve will also be transfered to parent view. Now it's upto the parent whether it wants to entertain those events or ignore them. if set to false, they are not added as direct children of the parent and the parent doesn't recieve any touch events from the views.

希望这将清除混乱

 
精彩推荐
图片推荐