动态添加RelativeLayout
和ImageView
,但是在模拟器中运行没显示
代码
RelativeLayout relativeLayout = new RelativeLayout(this);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
ImageView iv = new ImageView(this);
iv.setImageResource(R.drawable.freshface_mmm);
relativeLayout.addView(iv,lp);
你还要把你的relativeLayout添加到activity里.
addContentView(view, params)
ViewGroup relativeLayout = new RelativeLayout(getActivity());