gpt4 book ai didi

android - margin 不影响 "include"

转载 作者:IT王子 更新时间:2023-10-29 00:03:19 29 4
gpt4 key购买 nike

我对文章有看法。它使用“包含”,我试图在它们之间留出一点余地。但是,“android:layout_marginTop”似乎对布局没有任何影响。

我做错了什么?

<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>

最佳答案

您应该添加 android:layout_widthandroid:layout_height include 中的属性标签。否则,不考虑边距。

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

关于android - margin 不影响 "include",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11947987/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com