LayoutInflater加载布局时的inflate方法的第三个参数attachToRoot

  • 如果root为null,无论attachToRoot为true或者false,效果都是一样的

  • 如果root不为null,attachToRoot为true,表示将layout布局添加到root布局中

  • 如果root不为null,attachToRoot为false,表示不将layout布局添加到root布局,若要添加则需要手动addView

  • 如果root不为null,不设置attachToRoot(即调用两个参数的方法),情况和(2)中一样

猜你喜欢

转载自blog.csdn.net/asffghfgfghfg1556/article/details/80025228