当前位置: 首页 > wzjs >正文

张家口网站建设假冒网站能通过备案登记吗

张家口网站建设,假冒网站能通过备案登记吗,网站 维护 费用,空调维修网站模板前言 对于LayoutInflater.from(this).inflate()方法的几个参数以及用法总是迷迷糊糊,源码看了忘,忘了看,因此决定写这篇博客做下记录。 源码解析 我们知道,调用LayoutInflater.from(this).inflate()方法最终都会走三参的方法 p…

前言

对于LayoutInflater.from(this).inflate()方法的几个参数以及用法总是迷迷糊糊,源码看了忘,忘了看,因此决定写这篇博客做下记录。

源码解析

我们知道,调用LayoutInflater.from(this).inflate()方法最终都会走三参的方法
public View inflate(@LayoutRes int resource, @Nullable ViewGroup root, boolean attachToRoot)
,这里先简单说明下三个参数:

resource:表示需要加载资源的id;

root:表示resource资源需要被添加的根布局;

attachToRoot:表示resource是否需要被绑定到root上;

接下来我们重点分析下相关源码

inflate(@LayoutRes int resource, @Nullable ViewGroup root, boolean attachToRoot)

    public View inflate(@LayoutRes int resource, @Nullable ViewGroup root, boolean attachToRoot) {final Resources res = getContext().getResources();...View view = tryInflatePrecompiled(resource, res, root, attachToRoot);if (view != null) {return view;}XmlResourceParser parser = res.getLayout(resource);try {return inflate(parser, root, attachToRoot);//重点看这个代码} finally {parser.close();}}

inflate(parser, root, attachToRoot)

  public View inflate(XmlPullParser parser, @Nullable ViewGroup root, boolean attachToRoot) {synchronized (mConstructorArgs) {...View result = root; //result默认赋值为roottry {...if (TAG_MERGE.equals(name)) {.... //merge标签 这里不关注} else {// 将temp赋值为xml资源的根布局viewfinal View temp = createViewFromTag(root, name, inflaterContext, attrs);ViewGroup.LayoutParams params = null;if (root != null) {//如果传入的root参数不为空,则创建root对应的LayoutParamsparams = root.generateLayoutParams(attrs);if (!attachToRoot) {//如果传入的attachToRoot为false,则给temp布局设置LayoutParamstemp.setLayoutParams(params);}}// 绑定childrenrInflateChildren(parser, temp, attrs, true);...if (root != null && attachToRoot) {//如果root不为null并且attachToRoot为true时,将temp添加到root中,并设置对应的LayoutParamsroot.addView(temp, params);}if (root == null || !attachToRoot) {// root为null 或者 attachToRoot为false时,result = tempresult = temp;}}} catch (XmlPullParserException e) {final InflateException ie = new InflateException(e.getMessage(), e);ie.setStackTrace(EMPTY_STACK_TRACE);throw ie;} catch (Exception e) {final InflateException ie = new InflateException(getParserStateDescription(inflaterContext, attrs)+ ": " + e.getMessage(), e);ie.setStackTrace(EMPTY_STACK_TRACE);throw ie;} finally {// Don't retain static reference on context.mConstructorArgs[0] = lastContext;mConstructorArgs[1] = null;Trace.traceEnd(Trace.TRACE_TAG_VIEW);}return result; //返回结果}}

总结

  • 调用LayoutInflater.from(this).inflate(resource,null)不会将resource添加到布局中,结果返回resource资源根布局view,但不会设置对应的父布局LayoutParams属性【resource布局文件最外层的layout_width和layout_height等跟父布局有关的位置属性都会失效】;

  • 调用LayoutInflater.from(this).inflate(resource,root)会将resource添加到root布局中,同时会设置对应的父布局LayoutParams属性,结果返回root本身;

  • 调用LayoutInflater.from(this).inflate(resource,root,true)LayoutInflater.from(this).inflate(resource,root)方法效果一致,结果返回root本身;

  • 调用LayoutInflater.from(this).inflate(resource,root,false)不会将resource添加到root中,结果返回resource资源根布局view,同时会设置对应的父布局LayoutParams属性

  • 下面代码效果相同;

LayoutInflater.from(this).inflate(resource,root)
等同于
LayoutInflater.from(this).inflate(resource,root,true)
等同于
View resourceView = LayoutInflater.from(this).inflate(resource,root,false)
root.addView(resourceView)

结语

如果以上文章对您有一点点帮助,希望您不要吝啬的点个赞加个关注,您每一次小小的举动都是我坚持写作的不懈动力!ღ( ´・ᴗ・` )

http://www.dtcms.com/wzjs/805184.html

相关文章:

  • 南宁专业网站制作前十排名东莞网站建设 乐云seo
  • 北京网站制作公司转型方向企业名称预先核准通知书
  • 上海网站建设案例新浪博客seo
  • 哪个网站可以接程序项目来做wordpress装修门户
  • 游戏开发与网站开发哪个难推荐做木工的视频网站
  • 合肥网站建设专业设计seo是什么部门
  • 临汾哪做网站百度双站和响应式网站的区别
  • 梅江区建设局网站遂溪手机网站建设公司
  • dw做网站链接数据库中等职业学校示范建设专题网站
  • 重庆开发网站企业开办网站
  • 网站建设的书籍有哪些西安互联网设计公司
  • 答题助手网站怎么做的网站建设公司盈利分析
  • 丹江口市建设局网站网站建设公司的发展前景
  • 网站怎么做才有百度权重设计培训在线
  • 网站图片倒计时怎么做的只需要手机号的广告
  • 如何做与别人的网站一样的全屋整装十大排名全国前十强
  • led网站模板宁波seo关键词优化制作
  • 湛江网站建设策划要怎样夸一个网站做的好看
  • 网站开发颜色国外服装购物网站大全
  • 360网站推广建设网站需要几个文件夹
  • 洛阳网站建设好做不网页设计动态页面
  • 有什么好黄页网站怎么做淘宝返利网站吗
  • 网站新闻模板最超值的网站建设
  • 音乐网站禁止做浅度链接温州推广平台
  • 手机端网站制作教程企业网站开发介绍
  • 网站建设推广公司范围如何制定会员营销方案
  • 公司网站建设价格表wordpress 加载动画
  • 网站服务器价格如何搭建钓鱼网站
  • qingdao城乡住房建设厅网站长沙景点预约攻略
  • 网站建设临沂室内设计师收入高吗