How to use the merge tag for a RelativeLayout root?

两盒软妹~` 提交于 2019-12-10 19:01:52

问题


I have a custom view which extends RelativeLayout and has its content defined in a xml file (has RelativeLayout as its root).

How can I avoid having two RelativeLayouts after the inflation of my custom layout? I tried using the merge tag as my root at the xml, but that way I'm losing all my child views structure.


回答1:


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 the merge 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 a RelativeLayout)) 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.



来源:https://stackoverflow.com/questions/14674559/how-to-use-the-merge-tag-for-a-relativelayout-root

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