1.动态设置padding,拿ImageView为例:
- ImageView imageView = new ImageView(Context context);
- imageView.setPadding(left,top,right,bottom);
拿LinearLayout里边放ImageVIew例
- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(20, 20);
- params.setMargins(20, 0, 20, 0);
- imageView.setLayoutParams(params);