当父零膨胀: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。 –