在Android布局文件中使用<include>时,我无法覆盖属性.当我搜索错误时,我发现了拒绝问题2863:
"包括标签被破坏(覆盖布局参数永远不会起作用)"
由于Romain表明这在测试套件及其示例中有效,因此我必须做错事.
我的项目组织如下:
res/layout
buttons.xml
res/layout-land
receipt.xml
res/layout-port
receipt.xml
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
肖像和横向的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>
Run Code Online (Sandbox Code Playgroud)
我错过了什么?