Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Margin does not impact in "include"

I have a view with articles. It uses "include", and I'm trying to make a little margin between them. However, "android:layout_marginTop" does not seem to have any impact on the layout.

What am I doing wrong?

<LinearLayout      android:layout_width="match_parent"     android:layout_height="wrap_content"     android:orientation="vertical" >         <include android:id="@+id/article1" layout="@layout/mainarticle" />     <include android:id="@+id/article2" android:layout_marginTop="10dip" layout="@layout/article" />     <include android:id="@+id/article3" android:layout_marginTop="10dip" layout="@layout/article" />     <include android:id="@+id/article4" android:layout_marginTop="10dip" layout="@layout/article" />     <include android:id="@+id/article5" android:layout_marginTop="10dip" layout="@layout/article" />     </LinearLayout> 
like image 723
ohadinho Avatar asked Aug 14 '12 07:08

ohadinho


1 Answers

You should add the android:layout_width and android:layout_height attributes in the include tag. Otherwise, the margins are not taken into consideration.

However, if you want to override layout attributes using the <include> tag, you must override both android:layout_height and android:layout_width in order for other layout attributes to take effect.

https://developer.android.com/training/improving-layouts/reusing-layouts.html#Include

like image 108
Kamen Goranchev Avatar answered Oct 13 '22 20:10

Kamen Goranchev