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>
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 bothandroid:layout_height
andandroid:layout_width
in order for other layout attributes to take effect.
https://developer.android.com/training/improving-layouts/reusing-layouts.html#Include
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With