Android Studio项目中的MainActivity.xml与ContentActivity.xml

来源:互联网 发布:怎么做淘宝返利链接 编辑:程序博客网 时间:2024/06/16 22:06

最近比较闲,买了本《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文件。

个人理解,仅供参考。

0 0
原创粉丝点击