什么是rootView?

Seï*_*ach 3 android hierarchy

你好我是Android的新手,我用默认模板Master详细信息流打开了一个项目,但我不知道什么是rootView.我在developer.android.com上搜索,但我真的不明白......

因此,如果有人能够清楚地向我解释这件事有什么用,那将对我有所帮助.

谢谢 !

编辑:有代码!

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments().containsKey(ARG_ITEM_ID)) {
        mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
    }
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_item_detail, container, false);
    if (mItem != null) {
        mLinearLayout = (LinearLayout)findViewById(R.id.layout); 
    }
    return rootView;
}
Run Code Online (Sandbox Code Playgroud)

Swa*_*yam 17

RootView是放置所有其他视图的视图.它就像树结构中的根节点,它是所有子节点的父节点.

例如,布局中有多个按钮放在LinearLayout中.然后,LinearLayout被称为RootView,因为它在结构中具有最高位置,并且必须将所有内容放置在其中.

希望这能清除你的怀疑.