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文件。

个人理解,仅供参考。

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值