使用“合并”和“包含”

时间:2011-11-16 17:30:25

标签: android android-layout android-ui

我正在尝试使用“包含标记”将版权图片放在LinearLayout的底部。我正在成功地做到这一点,但是当我尝试将android:layout_marginTop="330dp"android:layout_marginBottom="20dp"添加到我的包含时 - 它不会在UI中显示。 有什么问题?

这是我的代码: copyrights.xml:

 <merge xmlns:android="http://schemas.android.com/apk/res/android">
    <ImageView
            android:src="@drawable/copyrights"
            android:id="@+id/copyrights"
            android:layout_width="fill_parent"
            android:layout_height="40dip"/>
</merge>

mylayout.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:padding="10dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">  
        <include layout="@layout/copyrights"  android:layout_marginTop="330dp"/>
    </LinearLayout>  

1 个答案:

答案 0 :(得分:0)

<include />标签基本上是android布局框架的复制和粘贴指令。它不是布局层次结构中的实际对象。这意味着它不能有margin / padding / size /任何其他布局属性。

将边距分配给布局中的<ImageView />