如何使用一个RelativeLayout的根合并标签? [英] How to use the merge tag for a RelativeLayout root?

查看:134
本文介绍了如何使用一个RelativeLayout的根合并标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个扩展的自定义视图 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 (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.

解决方案

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.

这篇关于如何使用一个RelativeLayout的根合并标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆