/**
* Inflate a new view hierarchy from the specified xml resource. Throws
* {@link InflateException} if there is an error.
*
* @param resource ID for an XML layout resource to load (e.g.,
* <code>R.layout.main_page</code>)
* @param root Optional view to be the parent of the generated hierarchy (if
* <em>attachToRoot</em> is true), or else simply an object that
* provides a set of LayoutParams values for root of the returned
* hierarchy (if <em>attachToRoot</em> is false.)
* @param 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.
* @return The root View of the inflated hierarchy. If root was supplied and
* attachToRoot is true, this is root; otherwise it is the root of
* the inflated XML file.
*/

inflate(int resource, ViewGroup root, boolean attachToRoot)

view=inflater.inflate(R.layout.fragment1, null,false)的三个参数详解;

第一个参数:加载view的布局文件。

第二个参数:

1.参数为空的情况,xml里的根布局(也就是最外层布局),将不会被加载(xml文件的根布局会失效);

2.不为空的情况,

系统会调用params = root.generateLayoutParams(attrs);//根据xml文件的宽,高 获取params

temp.setLayoutParams(params); 会把这个布局加载进去;也就是说xml文件的根布局不会失效;

第三个参数:

如果为true:

系统会调用:root.addView(temp, params); 会自动调用addview();

https://blog.csdn.net/dongpeng0314/article/details/51737899

inflate(int resource, ViewGroup root, boolean attachToRoot)见解的更多相关文章

  1. Android LayoutInflater.inflate(int resource, ViewGroup root, boolean attachToRoot)的参数理解

    方法inflate(int resource, ViewGroup root, boolean attachToRoot) 中 第一个参数传入布局的资源ID,生成fragment视图,第二个参数是视图 ...

  2. 6、Android之LayoutInflater.inflate()

    LayoutInflater.inflate()的作用就是将一个xml定义的布局文件实例化为view控件对象: 与findViewById区别: LayoutInflater.inflate是加载一个 ...

  3. 转载《 LayoutInflater 的inflate函数用法详解》

    很多人在网上问LayoutInflater类的用法,以及inflate()方法参数的含义,现解释如下: inflate()的作用就是将一个用xml定义的布局文件查找出来,注意与findViewById ...

  4. LayoutInflater中四种类型inflate方法的介绍

    转自:http://blog.csdn.net/aa4790139/archive/2011/05/07/6401556.aspx 第一种: public View inflate (int reso ...

  5. android LayoutInflater.inflate()的参数介绍

    LayoutInflater.inflate()的作用就是将一个xml定义的布局文件实例化为view控件对象: 与findViewById区别: LayoutInflater.inflate是加载一个 ...

  6. Android LayoutInflater.inflate()的参数及其用法

    很多人在网上问LayoutInflater类的用法,以及inflate()方法参数的含义,现解释如下: inflate()的作用就是将一个用xml定义的布局文件查找出来,注意与findViewById ...

  7. Android LayoutInflater.from(context).inflate

    在应用中自定义一个view,需要获取这个view的布局,需要用到 (LinearLayout) LayoutInflater.from(context).inflate(R.layout.conten ...

  8. android LayoutInflater和inflate()方法的用法(转载)

    原文出处:http://www.cnblogs.com/top5/archive/2012/05/04/2482328.html 在实际开发中LayoutInflater这个类还是非常有用的,它的作用 ...

  9. Android LayoutInflater.inflate使用上的问题解惑

    最近在在使用LayoutInflater.inflate方法时遇到了一些问题,以前没有仔细看过此类的使用方法,故将其记录下来,方便日后查阅. 相信大家都知道LayoutInflater.inflate ...

随机推荐

  1. ZMQ源代码分析(一)-- 基础数据结构的实现

    yqueue 和 ypipe zmq号称是"史上最快的消息队列",由此可见zmq中最重要的数据结构就是队列. zmq的队列主要由yqueue和ypipe实现.yqueue是队列的基 ...

  2. Unity5.1 新的网络引擎UNET(十五) Networking 引用--中

    孙广东 2015.7.21 本节提供了与网络系统一起使用的组件的具体信息. 3.NetworkClient NetworkClient 是一个 HLAPI 类,管理网络连接到服务器 - - 相应着 U ...

  3. C#实现马尔科夫模型例子

    已知条件:三个缸N状态,每个缸中不同颜色球的个数M状态值,时间轴T,观察值序列O 参数:状态值序列,转移概率序列 求:概率 后台代码如下 , M = ;//N状态,M状态值 (0橙色,1绿色,2蓝色, ...

  4. cocos2d-x之android编译环境搭建(第二篇)[版本号:cocos2d-x-3.1.1]

    基于 Android NDK 的学习之旅-----环境搭建 工欲善其事 必先利其器 , 以下介绍下 Eclipse SDK NDK Cygwin CDT 集成开发环境的搭建. 1.Android 开发 ...

  5. Oracle行转列,列转行,行列相互转换

    1.行转列 SELECT WM_CONCAT(COLUMN_NAME) COLUMN_NAME FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'T_CREATE_T ...

  6. Git下的冲突解决【转】

    本文转载自:http://www.cnblogs.com/sinojelly/archive/2011/08/07/2130172.html 冲突的产生 很多命令都可能出现冲突,但从根本上来讲,都是m ...

  7. 面向画布(Canvas)的JavaScript库

    面向画布(Canvas)的JavaScript库 总结 每个库各有特色,根据需求选择   学习要点 面向画布(Canvas)的JavaScript库 EaselJS 是一个封装了 HTML5 画布(C ...

  8. imagebutton 设置了src属性的图片更换

    <ImageButton android:id="@+id/mediacontroller_play_pause" android:layout_width="wr ...

  9. java dom4j 读写XML

    <?xml version="1.0" encoding="UTF-8"?> <Configuration> <Config id ...

  10. consul备份还原导入导出

    工作中要保证生产环境部署的consul的集群能够安全稳定地对外提供服务,即使出现系统故障也能快速恢复,这里将讲述部分的备份还原操作及KV的导入导出操作. 备份与还原 需要备份的主要有两类数据:cons ...