使用"合并"和"包括" [英] Using "merge" and "include"
问题描述
我试图把版权图像在我的的LinearLayout
的底部有一个包括标签。我这样做成功,但是当我试图添加的android:layout_marginTop =330dp
或的android:layout_marginBottom =20dp
比如我包括 - 它不显示在UI中。
有什么问题?
下面是我的code:
copyrights.xml:
<合并的xmlns:机器人=http://schemas.android.com/apk/res/android>
< ImageView的
机器人:SRC =@绘制/版权
机器人:ID =@ + ID /版权
机器人:layout_width =FILL_PARENT
机器人:layout_height =40dip/>
< /合并>
mylayout.xml:
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:填充=10dip
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT>
<包括布局=@布局/版权机器人:layout_marginTop =330dp/>
< / LinearLayout中>
的<包括/>
标签基本上是复制和放大器;对于Android的布局框架粘贴指令。这不是在你的布局层次结构一个实际的对象。这意味着它不能有保证金/填充/尺寸/任何其他布局属性。
分配缘至< ImageView的/方式>
在你的布局,而不是
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>
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.
这篇关于使用&QUOT;合并&QUOT;和&QUOT;包括&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!