当前位置: 代码迷 >> Android >> android setLayoutParams 有关问题,出错
  详细解决方案

android setLayoutParams 有关问题,出错

热度:38   发布时间:2016-04-28 02:38:46.0
android setLayoutParams 问题,出错
1             LinearLayout layt = (LinearLayout) rootView.findViewById(R.id.llt_2);2             FrameLayout.LayoutParams layoutParams=new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);3             layoutParams.gravity=Gravity.CENTER;            4             layt.setLayoutParams(layoutParams);

关键:

主是要是在定义layoutParams的时候要用view的父容器类去声明,而它本身,

new FrameLayout.LayoutParams参数也一样要用父,

可参考:http://blog.csdn.net/greenappple/article/details/7631430
  相关解决方案