如何使用一个RelativeLayout的根合并标签? [英] How to use the merge tag for a RelativeLayout root?
问题描述
我有一个扩展的自定义视图 RelativeLayout的
,并在一个XML文件(有 RelativeLayout的
定义它的内容其根)。
我如何避免两个 RelativeLayouts
我的自定义布局的充气后?
我尝试使用合并
标记为我在XML根,但这种方式我失去了我的所有子视图结构。
我尝试使用合并标记作为我的XML根,但这种方式我
失去了我所有子视图结构。
块引用>我对此表示怀疑。在
合并
标签的作品,没有任何问题,你只需要使用合并
标记布局文件的根目录,分配在该布局的孩子正确的规则。在Eclipse的图形编辑器这种布局是不行的(规则将被忽略(很正常的编辑器不知道你会使用该布局为一个RelativeLayout的
)),但是一个模拟器/真实设备上的规则将被应用。如果你有一个示例应用程序,其中规定不与工作
合并
标记不要害怕它张贴。I have a custom view which extends
RelativeLayout
and has its content defined in a xml file (hasRelativeLayout
as its root).How can I avoid having two
RelativeLayouts
after the inflation of my custom layout? I tried using themerge
tag as my root at the xml, but that way I'm losing all my child views structure.解决方案I tried using the merge tag as my root at the xml, but that way I'm losing all my child views structure.
I doubt that. The
merge
tag works with no problems, you just need to use themerge
tag as the root of the layout file and assign the proper rules for the children in that layout. In the Eclipse's graphical editor this layout will not work(the rules will be ignored(quite normal as the editor doesn't know you'll use that layout as the content of aRelativeLayout
)) but on an emulator/real device the rules will be applied.If you have a sample application where the rules don't work with a
merge
tag don't be afraid to post it.这篇关于如何使用一个RelativeLayout的根合并标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!