开发者

Is it possible to make an Android Layout, without just widgets?

开发者 https://www.devze.com 2023-01-22 14:57 出处:网络
Just something I have been thinking about. It is possible to create an android layout with just a TextView widget and no Layout code (e.g: inearLayout, ScrollLayout), but if I t开发者_StackOverflow社区

Just something I have been thinking about. It is possible to create an android layout with just a TextView widget and no Layout code (e.g: inearLayout, ScrollLayout), but if I t开发者_StackOverflow社区ry to add anything else to the XML file all sorts of errors start popping up. Is it possible to create a Layout with just widgets?

Also, if it is, how?


I don't think it's possible inside of an XML layout to have a layout of purely widgets and no ViewGroups. You would for one be creating an invalid XML doc (multiple roots since a widget cannot contain other widgets). Also you need a ViewGroup to hold multiple Views. You can create a merge and then decide on the view group later, however that is just a substitute for a ViewGroup. However it is the closest thing to an XML layout with only widgets in it, surrounded by a merge element as the root xml tag.


Yes it is possible to create layout with a single View (e.g. TextView). But if multiple Views are required you neeed to wrap them with a ViewGroup (e.g. LinearLayout)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号