在我的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