我有这段代码
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布局:(请注意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",但仍然没有效果。我的问题是,我在布局中放置的值没有被计算,不管有没有顶部边距,布局都是相同的。
我应该如何在项目之间添加一些空白? 我应该如何充气项目之间的空白? 是否可能充气间隙或某些空间? 还是必须像充气2dip高度的空布局这样使用解决方法? 谢谢
(Note: Translated text may not be an exact equivalent of the original in terms of formatting, style or tone.)
View
扩展并将其作为头部附加到ListView
上;如果我在扩展器中使用ListView
,它会抛出异常。在这种情况下,如何获取边距? - Andrew Wyld