Android:xml文件的文件名中的大写字母,以及命名xml文件的规则 [英] Android: capital letter in filename of xml file, and the rule of naming a xml file

查看:546
本文介绍了Android:xml文件的文件名中的大写字母,以及命名xml文件的规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在android项目的Java文件名中使用大写字母,但xml文件名中不允许使用大写字母.这种设计有什么好处?

It's ok to use capital letter in java file name in android project, but captial letter is not allowed in xml file name. What is the profit of this design?

我曾经这样命名xml文件:activity_xxx.命名有什么建议或规则吗?

I used to name xml file like this:activity_xxx. Is there any suggestion or rule in naming?

推荐答案

该问题似乎没有官方的答案. 资源是在R.java中自动定义的.例如,如果您有一个名为activity_test的布局,那么它将在R.java中生成public static final int activity_test=0x7f040034;.

It seems to be no official answer to this question. Resources are defined automatically in R.java. As an example, if you have a layout named activity_test then it will generate public static final int activity_test=0x7f040034; in R.java.

这一代不遵循android的常量命名约定. (请参见)

That generation doesn't follow android naming conventions for the constants. (See)

我认为,Android开发团队选择在生成的文件中避免使用此约定,以加快资源名称的键入速度(键入小写字母比使用大写字母更容易)

In my opinion, the Android dev team choosed to avoid this convention in this generated file in order to speed up the typing of the resource names (it is easier to type a lowercase letter than a capital letter)

如果在Android Studio上创建了项目,则基本资源的前缀是"activity _"(活动),"fragment _"(片段),"menu _"(菜单),因此写xml文件名似乎是正确的方法.

If a project is created on Android Studio, the basic resources are prefixed by "activity_" for activities, "fragment_" for fragments, "menu_" for menues so it seems to be right way to write an xml filename.

这篇关于Android:xml文件的文件名中的大写字母,以及命名xml文件的规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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