标签:
用LayoutParams:可以设定控件的一些属性
RelativeLayout insertLayout = (RelativeLayout)view1.findViewById(R.id.lay);//lay是一个RelativeLayout 布局的id ImageView img = new ImageView(MainActivity.this);//新建一个ImageView控件 img.setBackgroundColor(Color.parseColor("#ffbbb4")); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(100, 100); layoutParams.topMargin=8; layoutParams.leftMargin=8; layoutParams.rightMargin=8; layoutParams.bottomMargin=8; insertLayout.addView(imgApple2,layoutParams);
标签:
原文地址:http://www.cnblogs.com/mxxbaby/p/4564299.html