動態添加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)