为什么Android布局中的Fragment元素用小写的'f'书写? [英] Why is the Fragment element in Android layout written with a lower case 'f'?
问题描述
所有其他元素都以大写字母开头,例如RelativeLayout,TextView等.
All other elements start with an upper case letter, like RelativeLayout, TextView, etc.
是否存在将Fragment元素始终用作<fragment ... />
而不是<Fragment ... />
的特定原因?
Is there a particular reason why the Fragment element is always used as <fragment ... />
instead of <Fragment ... />
?
推荐答案
以XML定义的片段实际上不是视图.已指定完整视图名称,或者该名称假定包为android.view
并查找其余名称.但是,只有在包含android:name
标签时才真正指定片段.它的行为就像一个关键字,通常用小写字母书写.因此,Fragment
引用该类,而fragment
是XML中片段的占位符.
Fragments when defined in XML aren't actually views. The full view name is specified, or it assumes android.view
for the package and finds the rest. But a fragment is only truly specified when it includes the android:name
tag. It acts like a keyword, which are typically written in lower case. Thus, Fragment
refers to the class, and fragment
is the placeholder in XML for fragments.
如安德鲁(Andrew)在评论中所述,任何特殊项目(例如<include>
和<merge>
)均以小写形式编写,因为它们不是android.view
的.
As Andrew mentioned in the comments, any special item, such as <include>
and <merge>
are written in lower case, as they are not android.view
's.
这篇关于为什么Android布局中的Fragment元素用小写的'f'书写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!