Why is the Fragment element in Android layout written with a lower case 'f'?

六眼飞鱼酱① 提交于 2019-12-10 03:26:21

问题


All other elements start with an upper case letter, like RelativeLayout, TextView, etc.

Is there a particular reason why the Fragment element is always used as <fragment ... /> instead of <Fragment ... />?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/21948034/why-is-the-fragment-element-in-android-layout-written-with-a-lower-case-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!