LinearLayout layt = (LinearLayout) rootView.findViewById(R.id.llt_2);
FrameLayout.LayoutParams layoutParams=new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
layoutParams.gravity=Gravity.CENTER;
layt.setLayoutParams(layoutParams);
关键:
主是要是在定义layoutParams的时候要用view的父容器类去声明,而它本身,
new FrameLayout.LayoutParams参数也一样要用父, 可参考:http://blog.csdn.net/greenappple/article/details/7631430