• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question about XML in Android

 
Peter Sorotokin
Ranch Hand
Posts: 36
1
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I read in an Android tutorial that :

"In general, the XML vocabulary for declaring UI elements closely follows the structure and
naming of the classes and methods, where element names correspond to class names and
attribute names correspond to methods. In fact, the correspondence is often so direct that you can
guess what XML attribute corresponds to a class method, or guess what class corresponds to a
given xml element"

And

"Each layout file must contain exactly one root element, which must be a View or ViewGroup
object"

My Question is this : Why in XML layout files in res folder that i have seen there are no View or ViewGroup root element ???

Like this XML layout file :
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LinearLayout extends ViewGroup (as do all the other layout), so it is a ViewGroup for the purposes of a layout file. By that rationale, it is actually superfluous to mention ViewGroup there, because ViewGroup extends View - but maybe abstracting over two levels was too much for the documentation authors :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic