我有这个代码
View item = View.inflate(context, R.layout.item_layout, null);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
layout.addView(item, params);
我的 item_layout:(注意部分 android:layout_marginTop="2dip")
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:layout_marginTop="2dip" android:layout_width="fill_parent">
<ImageView android:src="@drawable/pic_unknown" android:id="@+id/image1"
android:layout_height="50dip" android:layout_width="50dip"
android:padding="5dip"></ImageView>
</RelativeLayout>
然后在我的布局中,我看到了膨胀的项目列表,但它们之间没有边距。我尝试使用 margintop=10dip 仍然没有发生我的观点是我在布局中输入的值在计算中没有考虑到有或没有边距顶部布局是相同的。
如何在项目之间添加一些空白空间?如何充气项目之间的空白空间?是否可以膨胀诸如 gap 或 some space 之类的东西?或者我必须使用解决方法,比如用 2dip 高度或其他东西膨胀一些空布局谢谢