當父零膨脹:LayoutInflater父
LayoutInflater I = getLayoutInflater();
RelativeLayout relativeLayout = (RelativeLayout)findViewById(R.id.Relative);
View v = I.inflate(R.layout.text,null);
relativeLayout.addView(v);
但是,當我使用此代碼:
LayoutInflater I = getLayoutInflater();
RelativeLayout relativeLayout = (RelativeLayout)findViewById(R.id.Relative);
View v = I.inflate(R.layout.text,relativeLayout);
文本PARAMS工作
text params work and hello word in center
爲什麼?
因爲您的相對佈局是視圖v的父級,所以您必須將第二個參數添加爲'relativeLayout'而不是null。 –
,因爲你的相對佈局是視圖v的父對象,所以你必須添加第二個參數作爲'relativeLayout'而不是null。 –