问题
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