一、include 用法

titlebar.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"xmlns:tools="http://schemas.android.com/tools"android:orientation="vertical"tools:background="#ff00ee"><Viewandroid:id="@+id/title_view"android:layout_width="match_parent"android:layout_height="0dp" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="45dp"><TextViewandroid:id="@+id/title_txt"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="测试"/><TextViewandroid:id="@+id/add_tv"android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_centerVertical="true"android:layout_alignParentRight="true"android:paddingRight="15dp"android:gravity="center"android:text="添加"/></RelativeLayout>
</LinearLayout>

应用include,code 如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#Fff00ee"><includeandroid:id="@+id/title"layout="@layout/titlebar"android:layout_width="match_parent"android:layout_height="50dp"android:visibility="gone"tools:visibility="visible"/>
</RelativeLayout>
include标签使用注意点:
1,在使用<include>标签时,可以重写所有layout属性的,include中指定的layout属性将会覆盖掉titlebar中指定的layout属性。
而非layout属性(如android:visibility="gone")则无法在<include>标签当中进行覆写。另外需要注意的是,如果想要在<include>标签当中覆写layout属性,必须要将layout_width和layout_height这两个属性也进行覆写,否则覆写效果将不会生效。
2,当一个xml布局文件中包含多个include标签的时候,需要为每个include设置ID,才能找到相应子View的控件,否则只能找到第一个include的layout布局,以及该布局的控件。
3,如果给include所加载的layout布局的根容器设置了id属性,也在include标签中设置了id属性,同时需要在代码中获取根容器的控件对象时,最好将这两个id设置相同的名称!否则,可能获取不到根容器对象,即为null。二、merge 用法

https://www.cnblogs.com/leipDao/p/8981687.html

include 用法相关推荐

  1. c++预处理命令 #include用法

    c++预处理命令 #include用法 #include 语法: #include 语法: #include <filename>#include "filename" ...

  2. php 前台include用法,php include与require用法介绍

    引用文件的方法有两种:require 及 include.两种方式提供不同的使用弹性. require 的使用方法如 require("MyRequireFile.php"); . ...

  3. C语言之#include用法详解

    学习Linux C,必须要理解include,只要弄清以下几个问题,就能完全理解include了! 1.#include 实质是什么? 预编译的时候copy include头文件的内容到当前行 (疑问 ...

  4. Nginx中的include用法

    include可以用在任何地方,前提是include的文件自身语法正确. include文件路径可以是绝对路径,也可以是相对路径,相对路径以nginx.conf为基准,同时可以使用通配符. 配置实例 ...

  5. C语言#include的用法详解

    #include叫做文件包含命令,用来引入对应的头文件(.h文件).#include 也是C语言预处理命令的一种. #include 的处理过程很简单,就是将头文件的内容插入到该命令所在的位置,从而把 ...

  6. c语言中assert函数,assert()函数用法总结

    assert宏的原型定义在中,其作用是如果它的条件返回错误,则终止程序执行,原型定义: #include void assert( int expression ); assert的作用是现计算表达式 ...

  7. 断言(assert)的用法

    我一直以为 assert 仅仅是个报错函数,事实上,它居然是个宏,并且作用并非"报错". 在经过对其进行一定了解之后,对其作用及用法有了一定的了解,assert() 的用法像是一种 ...

  8. include 和jspinclude和iframe的区别

    <%@include file="jsp/head.jsp" %>和jsp:include用法基本类似,但是jsp:include实质是2个servlet,而inclu ...

  9. JAVA函数assert的用法_assert()函数用法总结

    assert宏的原型定义在中,其作用是如果它的条件返回错误,则终止程序执行,原型定义: #includevoidassert(intexpression ); assert的作用是现计算表达式 exp ...

最新文章

  1. 社交网络图挖掘4--三角形计数问题
  2. python3.5安装-Linux:Python3.5安装和配置
  3. 案例二十、自动化运维-代码上线
  4. IPv6系列(一)—快速入门
  5. ack是什么,如何使用Ack机制,如何关闭Ack机制,基本实现,STORM的消息容错机制,Ack机制
  6. 如何用SAP WebIDE的Fiori创建向导基于ABAP OData service快速创建UI5应用
  7. 华为还是输了!双11战报出炉,离苹果仍有距离
  8. 自定义_Excel中的自定义函数(自定义函数的基础内容)
  9. 计算机组成原理白中英第五版之总线系统
  10. r语言和metawin_Meta分析系列之二_Meta分析的软件
  11. 解决echarts官网打不开访问失败问题
  12. 【平面设计基础】11:配色——配色原理
  13. OpenCV实现图片锐化
  14. 解决IAR编译警告Warning[Pa089]: enumerated type mixed with another enumerated type
  15. 阿里巴巴连接池mysql_阿里巴巴连接池(Druid)
  16. 小白学习java第11天多态抽象类接口
  17. 前端是什么,是干嘛的
  18. IAR使用ST-Link下载仿真
  19. JAVA语言的由来以及相关情况介绍
  20. Python 可视化--Matplotlib 安装和pyplot

热门文章

  1. 软件测试工程师的职业发展
  2. SAS、scsi、sata、ide硬盘有什么区别?
  3. 使用python提取轮廓做定制的毛笔字帖
  4. ubuntu 安装deb文件的安装方法
  5. 一般引起Cookie丢失的原因
  6. 使用excle 求z值、p值、置信度
  7. 一些蒟蒻认为的好题(趣题)【更新中】
  8. OGG19 Oracle之间的同步(经典架构)
  9. win7保存不了linux系统凭据,Win7无法保存凭据导致网络打印机脱机怎么办 解决方法介绍...
  10. Linux服务器上搭建WEB邮件系统Squirrelmail