Android Studio中的activity_main.xml和content_main.xml之间的确切区别是什么 [英] what is exact difference between activity_main.xml and content_main.xml in android studio

查看:168
本文介绍了Android Studio中的activity_main.xml和content_main.xml之间的确切区别是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在android studio的更新版本中,它会自动创建2个文件,我阅读了这些文件,但仍然感到困惑,因为两者的工作原理相似,因此,如何确定应该使用哪个文件放东西和代码,我应该在这两个文件中放什么东西?

In an updated version of android studio, it create 2 files automatically, I read about these files , but am still confused, as both work similarly, So how to decide which one should I use to put the things and code, what are the things I should put in these 2 files ?

推荐答案

这只是一个很酷的概念,其中 content_main.xml 布局仅包含在 activity_main.xml .因此,您必须将内容放入 content_main.xml .

This is just a cool concept , where by content_main.xml layout is just included inside the activity_main.xml. So you have to put your stuff in content_main.xml.

使用 activity_main.xml 的本质是在 content_main.xml 布局的顶部插入其他小部件,例如(Floating Action Bar).

The essence of using activity_main.xml is to insert other widgets such as (Floating Action Bar ) on top of a content_main.xml layout.

基本上,这种方法只是教会我们如何将 xml 文件包含到其他文件中,而不是使一个 xml 中的多个组件变得拥挤代码>文件.

There for basically , this approach just teaches us on how to include an xml file into the others , instead of congesting several components in one xml file.

总而言之,您只需编辑 content_main.xml 布局

这篇关于Android Studio中的activity_main.xml和content_main.xml之间的确切区别是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆