我在 xml 中定义了一个 ListView ,如下所示
<ListView android:id="@+id/mylist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:layout_weight="1"
android:layout_marginTop="95dip"/>
我需要根据程序中的某些结果重新定义布局边距,我该如何实现这一点
最佳答案
更简单地说,您可以修改现有的 MarginLayoutParams 实例来修改边距:
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) mListView
.getLayoutParams();
mlp.setMargins(adjustmentPxs, 0, 0, 0);
break;
关于android - 如何以编程方式更改 Android ListView 的布局边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3061579/