Using “merge” and “include”

怎甘沉沦 提交于 2019-12-13 15:22:35

问题


I'm trying to put a copyright image in the bottom of my LinearLayout with an "include tag". I am doing it successfully, but when I'm trying to add android:layout_marginTop="330dp" or android:layout_marginBottom="20dp" for instance to my include - it doesn't show in the UI. What is the problem ?

Here is my code: 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:


The <include /> tag is basically a copy&paste instruction for the android layout framework. It's not an actual object in your layout hierachy. That means that it can't have margin/padding/size/any other layout property.

Assign the margin to the <ImageView /> in your layout instead.



来源:https://stackoverflow.com/questions/8156010/using-merge-and-include

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!