1. 程式人生 > >android 動態新增ImageView 設定setPadding不起作用問

android 動態新增ImageView 設定setPadding不起作用問

imageView = new ImageView(this); 
imageView.setLayoutParams(new LayoutParams(20,20)); 
imageView.setPadding(20, 0, 20, 0);

設定ImageView的setPadding(20, 0, 20, 0); 不起作用

改為

            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(25, 25); 

            params.setMargins(15, 0, 15, 0);

            ImageView imageView = new ImageView(this);

            imageView.setLayoutParams(params);

            imageViews[i] = imageView;

轉載地址:

http://www.cnblogs.com/freexiaoyu/archive/2013/04/10/3012135.html