最近比较闲,买了本《Android疯狂讲义(第三版)》开始自学Android应用的开发。书中介绍的默认布局文件是MainActivity.xml,而在Android Studio中新建project后,在Layout文件中会生成两个xml文件,分别是MainActivity.xml和ContentActivity.xml,而书中所描述的、等标签也是位于Content.xml文件中的。于是去Google了一下两个xml文件的关系:

According to new design pattern in android studio activity_main.xml will determine how the look of the main activity should be. And on the other hand content_main.xml will determine the contents in the activity_main.xml. That is content_main.xml will contain the textview, edittext, button etc component. And the content_main.xml will be included by the activity_main.xml .

So we can think of content_main.xml just like partial in HTML. activity_main.xml will contain your activity global design, and content_main.xml the contents.

http://stackoverflow.com/questions/32880722/what-is-the-role-of-content-main-xml-in-android-studio-1-4

也就是说,MainActivity用于显示coordinatorLayout,tabLayout,floatingActionButton,viewPager等控件;而ContentActivity用于显示你自己的控件,TextView,ImageView等等。新版的界面设计思路即把用户控件从系统控件中独立出来,分别管理,最后再从MainActivity中include ContentActivity文件。

个人理解,仅供参考。

更多相关文章

  1. 2010-02-27 传智播客—Android(二)数据存储和访问 之文件
  2. Android 中的时间日期控件
  3. 通过修改hosts文件成功更新Android sdk .
  4. 全面认识Android中Gradle相关配置文件
  5. Android APK开发 Drawable文件夹下的自定义Drawable文件
  6. Android项目文件结构
  7. IKNinePhotoView 是一个开源的 Android 九宫格控件,可以自适应宽
  8. Android之——自定义复合控件的实现
  9. Android Studio中创建Selector文件的方法

随机推荐

  1. 用Node.js创建安全的 GraphQL API[每日前
  2. 奥斯卡,究竟谁一直在陪跑。
  3. 如何正确使用Node.js事件[每日前端夜话0x
  4. JavaScript 中的强制类型转换[每日前端夜
  5. 大江大河,一代人的缩影。
  6. 用Python生成抖音字符视频!
  7. 用Python将HTML转为PDF。
  8. 怎样与 CORS 和 cookie 打交道[每日前端
  9. 我怎样用Node.js自动完成工作的[每日前端
  10. 学习C语言的历程