Android Studio项目中的MainActivity.xml与ContentActivity.xml
最近比较闲,买了本《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文件。
个人理解,仅供参考。
更多相关文章
- 2010-02-27 传智播客—Android(二)数据存储和访问 之文件
- Android 中的时间日期控件
- 通过修改hosts文件成功更新Android sdk .
- 全面认识Android中Gradle相关配置文件
- Android APK开发 Drawable文件夹下的自定义Drawable文件
- Android项目文件结构
- IKNinePhotoView 是一个开源的 Android 九宫格控件,可以自适应宽
- Android之——自定义复合控件的实现
- Android Studio中创建Selector文件的方法