Android 动态添加View并设置padding

来源:互联网 发布:机器视觉算法与应用 编辑:程序博客网 时间:2024/05/24 06:41

Android 动态添加View并设置padding

动态设置padding

LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(10, 10);            layoutParams.setMargins(10,0,10,0);            iv_point.setLayoutParams(layoutParams);            ivPointArray[i] = iv_point;            //第一个页面需要设置为选中状态,这里采用两张不同的图片            if (i == 0) {                iv_point.setBackgroundResource(R.drawable.dot_red);            } else {                iv_point.setBackgroundResource(R.drawable.dot_gray);            }            //将数组中的ImageView加入到ViewGroup            llGoodDetailDot.addView(ivPointArray[i],layoutParams);
0 0