1.动态设置padding,拿ImageView为例:
ImageView imageView = new ImageView(this);
imageView.setPadding(5,5,5,5)
2.动态设置margin
拿LinearLayout里边放ImageVIew例:
LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.linearlayout);
ImageView imageView = new ImageView(this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(100, 100);
params.setMargins(5, 5, 5, 5);
layout.addView(imageView);