android studio 1.4中content_main.xml的作用是什么? [英] What is the role of content_main.xml in android studio 1.4?

查看:28
本文介绍了android studio 1.4中content_main.xml的作用是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的 android studio 更新到了 android studio1.4 的最新版本.

I updated my android studio to latest version that is android studio1.4.

默认情况下,在新项目中,布局文件夹中有一个文件 content_main.xml.
这个文件有什么用?

By default in a new project, there is a file content_main.xml in layout folder.
What is the use of this file?

推荐答案

根据android studio中新的设计模式activity_main.xml 将决定Activity的全局UI应该如何.另一方面,content_main.xml 将决定 activity_main.xml 中的内容.

According to new design pattern in android studio activity_main.xml will determine how the global UI of the Activity should be. And on the other hand content_main.xml will determine the contents in the activity_main.xml.

content_main.xml 将包含 textview、edittext、button 等组件.它将包含在 activity_main.xml 中.

That is content_main.xml will contain the textview, edittext, button etc component. And it will be included by the activity_main.xml.

所以我们可以把 content_main.xml 想象成 HTML 中的部分.activity_main.xml 将包含您的 Activity 全局设计,content_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 will contain the contents.

从它们所包含的内容来看:

From view of what they contain:

activity_main : Co-ordinator 布局,ViewPager 等

activity_main : Co-ordinator layout, ViewPager etc

content_main :开发者选择的元素.文本视图、编辑文本、按钮等.

content_main : Developer choosen elements. textview, edittext, button etc.

android 开发者网站对他们的评价是

activity_main:

此 XML 布局文件用于您在创建时添加的活动Android Studio 项目.遵循新项目工作流程,Android Studio 以文本视图和预览呈现此文件的屏幕 UI.该文件包含一些默认的界面元素来自材料设计库,包括应用栏和浮动动作按钮.它还包括一个单独的布局文件,其中包含主要的内容

This XML layout file is for the activity you added when you created the project with Android Studio. Following the New Project workflow, Android Studio presents this file with both a text view and a preview of the screen UI. The file contains some default interface elements from the material design library, including the app bar and a floating action button. It also includes a separate layout file with the main content

content_main:

此 XML 布局文件位于 activity_my.xml (activity_main) 中,并包含一些设置和 Textview(other) 元素.

This XML layout file resides in activity_my.xml (activity_main) , and contains some settings and Textview(other) element.

这篇关于android studio 1.4中content_main.xml的作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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