标签:class image 而且 显示 setimage set add color content
ImageView imageView = new ImageView(mActivity); imageView.setImageResource(R.mipmap.gengduo); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT); param.leftMargin = 40; param.gravity = Gravity.CENTER; //必须要加上这句,setMargins才会起作用,而且此句还必须在setMargins下面 imageView.setLayoutParams(param); linearLayout.addView(imageView);
动态的添加ImageView到LinearLayout中并居中显示
标签:class image 而且 显示 setimage set add color content
原文地址:https://www.cnblogs.com/Free-Thinker/p/8921113.html