在我的Android布局文件中使用<包括>时,我无法覆盖属性。当我搜索的错误,我发现拒绝Issue 2863:Android XML布局的“包含”标签真的有用吗?
“包括标签坏了(覆盖布局PARAMS从未工程)”
由于罗曼表示这部作品在测试套件和他的例子,我必须做的事情错误。
我的项目是组织这样的:
res/layout
buttons.xml
res/layout-land
receipt.xml
res/layout-port
receipt.xml
的buttons.xml包含这样的事情:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button .../>
<Button .../>
</LinearLayout>
而且纵向和横向receipt.xml文件看起来是这样的:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
...
<!-- Overridden attributes never work. Nor do attributes like
the red background, which is specified here. -->
<include
android:id="@+id/buttons_override"
android:background="#ff0000"
android:layout_width="fill_parent"
layout="@layout/buttons"/>
</LinearLayout>
我错过了什么?
这是荒谬的。我从来没有能够得到这个工作,我甚至看到提及需要高度和宽度的文档,如果试图覆盖尺寸,我认为它是高度和宽度。然而,我试图覆盖的是边际,这不是一个维度。为什么当我想要改变的是layout_marginRight时,我需要指定这些还是其中的任何一个? Grrr,安卓系统,有时你让我感到沮丧。 – 2010-12-14 02:06:17
埃里克,你应该接受你自己的答案作为解决方案。 – 2010-12-14 02:06:41
仅供参考如果您不覆盖高度和宽度属性 – binary 2015-01-16 21:46:05