以前用的这种方式:
inflate布局
filterLayout = (FrameLayout) inflater.inflate(R.layout.camera_photo_filter, null);
然后再:
创建params
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, activity
.getResources().getDimensionPixelSize(R.dimen.bottom_bar_height_optimal));
params.gravity = Gravity.BOTTOM;
添加view:
mModeListView.addView(filterLayout,params);
然后觉得很奇怪,为啥我在xml中写了 paramas,还要 new params 呢?
于是抱着试试看的态度
filterLayout = (FrameLayout) inflater.inflate(R.layout.camera_photo_filter, null)
mModeListView.addView(filterLayout);
发现params没有生效
最后解决方法:
filterLayout = (FrameLayout) inflater.inflate(R.layout.camera_photo_filter, mModeListView);
一句话就好了
害我搞半天